1、創建用戶表空間
--創建臨時表空間 --查詢臨時表空間文件的絕對路徑。如果需要的話,可以通過查詢來寫定絕對路徑。一般用${ORACLE_HOME}就可以了 --查詢ORACLE_HOME: echo $ORACLE_HOME select name from v$tempfile; --查詢到的表空間為/u01/app/oracle/oradata/orcl/temp01.dbf create temporary tablespace NOTIFYDB_TEMP tempfile '\u01\app\oracle\oradata\NOTIFYDB_TEMP.bdf' size 100m reuse autoextend on next 20m maxsize unlimited; --創建表空間 --查詢用戶表空間文件的絕對路徑: select name from v$datafile; create tablespace NOTIFYDB datafile '\u01\app\oracle\oradata\notifydb.dbf' size 100M reuse autoextend on next 40M maxsize unlimited default storage(initial 128k next 128k minextents 2 maxextents unlimited); --創建用戶和密碼,指定上邊創建的臨時表空間和表空間 create user hc_notify identified by hc_password default tablespace NOTIFYDB temporary tablespace NOTIFYDB_TEMP; --賦予權限 grant dba to hc_notify; grant connect,resource to hc_notify; grant select any table to hc_notify; grant delete any table to hc_notify; grant update any table to hc_notify; grant insert any table to hc_notify;
2、刪除表空間
--查看用戶權限 --查看用戶要具備drop tablespace的權限,如果沒有,先用更高級的用戶(如sys)給予授權 select a2.username,a1.privilege from dba_sys_privs a1 , user_role_privs a2 where a1.privilege = 'DROP TABLESPACE' and a1.grantee =a2.granted_role --刪除臨時表空間 --查看臨時表空間文件 select name from v$tempfile; --查看用戶和表空間的關系 select USERNAME,TEMPORARY_TABLESPACE from DBA_USERS; --如果有用戶的默認臨時表空間是NOTIFYDB_TEMP的話,建議進行更改 alter user xxx temporary tablespace tempdefault; ---設置tempdefault為默認臨時表空間 alter database default temporary tablespace tempdefault; --刪除表空間NOTIFYDB_TEMP及其包含數據對象以及數據文件 drop tablespace NOTIFYDB_TEMP including contents and datafiles; --刪除用戶表空間 --查看表空間文件 select name from v$datafile; --停止表空間的在線使用 alter tablespace 表空間名稱 offline; --刪除表空間NOTIFYDB_TEMP及其包含數據對象以及數據文件 drop tablespace NOTIFYDB_TEMP including contents and datafiles; --Oracle用戶權限查詢相關操作: --查看所有的用戶 select * from all_users; --查看當前用戶信息 select * from user_users; --查看當前用戶的角色 select * from user_role_privs; --查看當前用戶的權限 select * from user_sys_privs; --查看當前用戶的表可操作權限 select * from user_tab_privs; --查看某一個表的約束,注意表名要 大寫 select * from user_constraints where table_name='TBL_XXX'; --查看某一個表的所有索引,注意表名要 大寫 select index_name,index_type,status,blevel from user_indexes where table_name = 'TBL_XXX'; --查看索引的構成,注意表名要 大寫 select table_name,index_name,column_name, column_position FROM user_ind_columns WHERE table_name='TBL_XXX'; --系統數據字典 DBA_TABLESPACES 中記錄了關於表空間的詳細信息 select * from sys.dba_tablespaces; --查看用戶序列 select * from user_sequences; --查看數據庫序列 select * from dba_sequences;