oracle新建用戶相關操作

oracle新建用戶相關操作
查看用戶及表空間

select username,default_tablespace from dba_users;

–查看錶空間 USERS 信息

select t.*  from sys.dba_data_files t where t.tablespace_name ='USERS';

查詢當前數據庫中表空間SEC_D是否爲自動擴展

select tablespace_name,file_name,autoextensible from dba_data_files where tablespace_name = 'SEC_D';

通過修改SEC_D的數據文件爲自動擴展達到表空間SEC_D爲自動擴展的目的

alter database datafile '/u01/app/oracle/oradata/orcl/sec_d01.dbf' autoextend on;

新建表空間:

create tablespace NEW_TABLESPACENAME datafile ‘dir’ size 1024M reuse;

還有一種方法是在創建表空間的設置自增加屬性,這樣在表空間不足的時候會自己增加,這是一種比較合理的策略

create tablespace NEW_TABLESPACENAME datafile 'dir' size 1M autoextend on next 50M maxsize unlimited; 

autoextend 自動增長 50M是自增的大小

例如:

create tablespace test_db_data datafile 'test_db_data.dbf' size 10240M autoextend on next 2048M maxsize unlimited;

–刪除用戶:

drop user USERNAME cascade;
cascade:刪除用戶下的所有數據

–新建用戶

create user USERNAME identified by " PASSWORD" default tablespace TABLESPACENAME 
profile DEFAULT ACCOUNT UNLOCK;

–給新建用戶授DBA權限

grant create session to NEW_USERNAME;
grant dba to NEW_USERNAME;
grant unlimited tablespace to NEW_USERNAME;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章