Oracle建立資料表空間和使用者

來源:互聯網
上載者:User

標籤:

Oracle建立資料表空間和使用者                 
 

[sql] view plain copy
  1. 建立資料表空間和使用者的步驟:  
  2. 使用者  
  3. 建立:create user 使用者名稱 identified by "密碼";  
  4. 授權:grant create session to 使用者名稱;  
  5.             grant create table to  使用者名稱;  
  6.             grant create tablespace to  使用者名稱;  
  7.             grant create view to  使用者名稱;  

 

[sql] view plain copy
  1. 資料表空間  
  2. 建立資料表空間(一般建N個存資料的資料表空間和一個索引空間):  
  3. create tablespace 資料表空間名  
  4. datafile ‘ 路徑(要先建好路徑)\***.dbf  ‘ size *M  
  5. tempfile ‘ 路徑\***.dbf ‘ size *M  
  6. autoextend on  --自動成長  
  7. --還有一些定義大小的命令,看需要  
  8.  default storage(  
  9.  initial 100K,  
  10.  next 100k,  
  11. );  
[sql] view plain copy
  1. 例子:建立資料表空間  
  2. create tablespace DEMOSPACE   
  3. datafile ‘E:/oracle_tablespaces/DEMOSPACE_TBSPACE.dbf‘   
  4. size 1500M   
  5. autoextend on next 5M maxsize 3000M;  
  6. 刪除資料表空間  
  7. drop tablespace DEMOSPACE including contents and datafiles  

 

[sql] view plain copy
  1. 使用者權限  
  2. 授予使用者使用資料表空間的許可權:  
  3. alter user 使用者名稱 quota unlimited on 資料表空間;  
  4. 或 alter user 使用者名稱 quota *M on 資料表空間;  


完整例子:

[sql] view plain copy
  1. --資料表空間  
  2. CREATE TABLESPACE sdt  
  3. DATAFILE ‘F:\tablespace\demo‘ size 800M  
  4.          EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;   
  5. --索引資料表空間  
  6. CREATE TABLESPACE sdt_Index  
  7. DATAFILE ‘F:\tablespace\demo‘ size 512M           
  8.          EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;       
  9.   
  10. --2.建使用者  
  11. create user demo identified by demo   
  12. default tablespace demo;  
  13.    
  14. --3.賦權  
  15. grant connect,resource to demo;  
  16. grant create any sequence to demo;  
  17. grant create any table to demo;  
  18. grant delete any table to demo;  
  19. grant insert any table to demo;  
  20. grant select any table to demo;  
  21. grant unlimited tablespace to demo;  
  22. grant execute any procedure to demo;  
  23. grant update any table to demo;  
  24. grant create any view to demo;  
[sql] view plain copy
  1. --匯入匯出命令     
  2. ip匯出方式: exp demo/[email protected]:1521/orcl file=f:/f.dmp full=y  
  3. exp demo/[email protected] file=f:/f.dmp full=y  
  4. imp demo/[email protected] file=f:/f.dmp full=y ignore=y 
建表時的一些參數pctfree initrans maxtrans storage的含義 Create table 
create table X_SMALL_AREA 

SMALL_AREA_ID NUMBER(10) not null 

tablespace TBSL_SDDQ --表段X_SMALL_AREA放在資料表空間TBSL_SDDQ中
pctfree 10 --塊保留10%的空間留給更新該塊資料使用
initrans 1 --初始化事務槽的個數
maxtrans 255 --最大事務槽的個數
storage --儲存參數

initial 64k --區段(extent)一次擴充64k
minextents 1 --最小區段數
maxextents unlimited --最大區段無限制 
);

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.