標籤: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_ 一個建立資料表空間、建立使用者、授權的完整過程