Oracle學習筆記_05_ 一個建立資料表空間、建立使用者、授權的完整過程

來源:互聯網
上載者:User

標籤:user   使用者   username   bsp   style   linu   tab   cal   sel   

一、完整命令

 

su - oraclesqlplus /nologconn /as sysdbacreate tablespace scaninvoice logging datafile ‘/u01/app/oracle/oradata/mas/scaninvoice.dbf‘ size 200M autoextend on next 100m  extent management local;create temporary tablespace scaninvoice_tmp tempfile ‘/u01/app/oracle/oradata/mas/scaninvoice_tmp.dbf‘ size 50m autoextend on next 50m maxsize 20480m extent management local;create user  username  identified by password default tablespace scaninvoice temporary tablespace scaninvoice_tmp;        grant dba to trainhec ;grant dba,create session,resource,connect to trainhec ;exit;  

 

 

二、完整過程1.以root使用者登入linux,然後切換到oracle使用者,以sysdba的身份登入oracle
# su - oracle$ sqlplus /nologSQL> conn /as sysdba

 

2.建立資料表空間和暫存資料表空間

2.1 資料表空間: 一般在開發情況下,我們當然不會使用使用者的預設資料表空間,所以這時我們需要建立一個資料表空間. 

create tablespace scaninvoice logging datafile ‘/u01/app/oracle/oradata/mas/scaninvoice.dbf‘ size 200M autoextend on next 100m  extent management local;

 

註:datafile後面是資料表空間的實體儲存體路徑,檔案名稱的尾碼可以隨便. 若沒有dbf檔案,則系統會自動建立。

2.2 暫存資料表空間

create temporary tablespace scaninvoice_tmp tempfile ‘/u01/app/oracle/oradata/mas/scaninvoice_tmp.dbf‘ size 50m autoextend on next 50m maxsize 20480m extent management local;

 

3.建立使用者
create user  username  identified by password;    //使用預設資料表空間 USERcreate user  username  identified by password default tablespace scaninvoice temporary tablespace scaninvoice_tmp;            //指定預設資料表空間和暫存資料表空間  (推薦)

 

4.授權使用者
grant dba to trainhec ;grant dba,create session,resource,connect to trainhec ;
exit;

 

三、附加命令1.修改使用者密碼
alter user username  identified by password; 

 

2.查看所有使用者所在的資料表空間

預設情況下使用者建立好後系統會預設給該使用者指派一個資料表空間(users); 我們可以通過下面的sql語句來查看一下所有使用者所在的資料表空間. 

select username,default_tablespace from dba_users;  

 

3.將資料表空間分配給使用者
alter user scaninvoice default tablespace scaninvoice;  

 

 

四、參考資料

1. Oracle建立資料表空間、建立使用者以及授權 

 

Oracle學習筆記_05_ 一個建立資料表空間、建立使用者、授權的完整過程

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.