Oracle代碼 規則 建立表 資料表空間 使用者等

來源:互聯網
上載者:User

標籤:


-----建立資料表空間----------
create tablespace bdccs
logging datafile ‘D:\oracle\product\10.2.0\oradata\bdccs\bdccs.dbf‘
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
-----建立使用者到資料表空間上------------------
create user bdccs identified by bdccs
default tablespace bdccs
temporary tablespace temp;

------給使用者授權------------
grant connect to bdccs;
grant resource to bdccs;
grant dba to bdccs;


---------如何匯入dmp檔案--------------
imp platform/[email protected] file=‘d:/platform.dmp‘fromuser=platform touser=platform
imp gisqbpm/[email protected] file=‘d:/gisqbpm.dmp‘fromuser=gisqbpm touser=gisqbpm
(注:格式為 imp 使用者名稱/密碼@執行個體名 file=’檔案所在路徑’)


----刪除使用者----
dropuser PLATFORM cascade
(注:刪除的時候可能會提示”無法刪除當前已連線的使用者”,把此使用者登陸的pl/sql關掉,相關的tomcat停掉,重啟oracle服務)
--------刪除資料表空間----
drop tablespace PLATFORM including contents and datafiles


--建立T_Test表---------
create table T_Test
(
TestID number(3) not null primary key

)
(注:T_Test建立的表名,TestI欄位 ,number(3)類型,primary key主鍵)


--設定自增主鍵-----建立序列-----------------
create sequence Test_seq
minvalue 1
maxvalue 2222222222
start with 1
increment by 1
cache 20;


-----建立觸發器-----
create or replace trigger Tr_Test1
before insert on T_Test for each row
begin
select Test_seq.nextval into :new.TestID from dual;
end Tr_Test;(註:Tr_Test1觸發器名字,T_Test 為T_Test表建立,)


---添加一個欄位---
alter table t_test add myname Varchar(2)

---插入資料--
insert into t_test (MYNAME) values(‘aa‘);
insert into t_test (MYNAME) values(‘bb‘);

---=添加一個欄位---
alter table t_test add age number(3)

---=刪除一個欄位---
alter table t_test drop column age

---刪除資料----
delete T_test where TestID=5;

----輸出表格所有內容---
select * from t_test;-


----輸出表格指定內容---
select TestID as 編號,MYNAME as 名字 from T_Test;

 


-建表
create table my_test_table_20110414
(
aa number,
bb varchar2(10)
);

--修改表結構
alter table my_test_table_20110414 add cc varchar2(10);

alter table my_test_table_20110414 modify cc varchar2(100);

--修改表資料內容
--插入
insert into my_test_table_20110414(aa,bb)
values (1,‘2‘);
commit;

--查詢
select * from my_test_table_20110414;

--修改
update my_test_table_20110414
set cc=‘test‘
where aa=1;
commit;


建立資料表空間(帶參數):
CREATE Tablespace zfmi logging datafile ‘D:oracleoradatazfmizfmi.dbf‘
size 100m
autoextend on next 32m
maxsize 2048m extent
management local;

建立暫存資料表空間(帶參數):
CREATE Temporary tablespace zfmi_temp tempfile ‘D:oracleoradatazfmizfmi_temp.dbf‘
size 100m
autoextend on next 32m
maxsize 2048m extent
management local;

參數說明:
Size:指定資料表空間資料庫檔案的初始大小
Autoextend:資料表空間自動成長的大小
Maxsize:資料表空間最大的大小
UNIFORM SIZE:指定區尺寸, 預設為64k
Pctfree:用於控制資料區塊中空閑空間
Initrans:用於控制訪問資料區塊的事務數量,也會影響資料區塊頭部空間的使用方式
Maxtrans:用於決定資料區塊的事務總數
Management local:預設的管理方式

使資料表空間離線:
ALTER TABLESPACE table_space name OFFLINE;
使資料表空間聯機
ALTER TABLESPACE table_space name ONLINE;
使資料檔案離線
ALTER DATABASE datafile name OFFLINE;
使資料檔案聯機
ALTER DATABASE datafile name ONLINE;
使資料表空間唯讀
ALTER TABLESPACE table_space name READ ONLY;
使資料表空間可讀寫
ALTER TABLESPACE table_space name READ WRITE;
-建表
create table my_test_table_20110414
(
aa number,
bb varchar2(10)
);

--修改表結構
alter table my_test_table_20110414 add cc varchar2(10);

alter table my_test_table_20110414 modify cc varchar2(100);

--修改表資料內容--插入
insert into my_test_table_20110414(aa,bb)
values (1,‘2‘);
commit;

--查詢
select * from my_test_table_20110414;

--修改
update my_test_table_20110414
set cc=‘test‘
where aa=1;
commit;


建立資料表空間(帶參數):
CREATE Tablespace zfmi logging datafile ‘D:oracleoradatazfmizfmi.dbf‘
size 100m
autoextend on next 32m
maxsize 2048m extent
management local;

建立暫存資料表空間(帶參數):
CREATE Temporary tablespace zfmi_temp tempfile ‘D:oracleoradatazfmizfmi_temp.dbf‘
size 100m
autoextend on next 32m
maxsize 2048m extent
management local;

參數說明:
Size:指定資料表空間資料庫檔案的初始大小
Autoextend:資料表空間自動成長的大小
Maxsize:資料表空間最大的大小
UNIFORM SIZE:指定區尺寸, 預設為64k
Pctfree:用於控制資料區塊中空閑空間
Initrans:用於控制訪問資料區塊的事務數量,也會影響資料區塊頭部空間的使用方式
Maxtrans:用於決定資料區塊的事務總數
Management local:預設的管理方式

使資料表空間離線:
ALTER TABLESPACE table_space name OFFLINE;
使資料表空間聯機
ALTER TABLESPACE table_space name ONLINE;
使資料檔案離線
ALTER DATABASE datafile name OFFLINE;
使資料檔案聯機
ALTER DATABASE datafile name ONLINE;
使資料表空間唯讀
ALTER TABLESPACE table_space name READ ONLY;
使資料表空間可讀寫
ALTER TABLESPACE table_space name READ WRITE;

刪除資料表空間:
DROP TABLESPACE table_space name INCLUDING CONTENTS AND DATAFILES;

建立使用者
CREATE USER user
IDENTIFIED BY password;
DROP TABLESPACE table_space name INCLUDING CONTENTS AND DATAFILES;

建立使用者
CREATE USER user
IDENTIFIED BY password;

 

Oracle代碼 規則 建立表 資料表空間 使用者等

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.