Oracle學習筆記_05_ 一個創建表空間、創建用戶、授權的完整過程
阿新 • • 發佈:2017-11-22
查看 ref tab 學習 linu word 切換 temp voice
一、完整命令
su - oracle sqlplus /nolog conn /as sysdba create 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 passworddefault 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 /nolog SQL> 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; //使用默認表空間 USER create 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_ 一個創建表空間、創建用戶、授權的完整過程