《oracle创建表空间用户及授权查看权限》由会员分享,可在线阅读,更多相关《oracle创建表空间用户及授权查看权限(13页珍藏版)》请在金锄头文库上搜索。
1、Oracle 创创建表空建表空间间、 、创创建用建用户户以及授以及授权权、 、查查看看权权 限限一、一、创创建建临时临时表空表空间间# sqlplus / as sysdba;sql CREATE TEMPORARY TABLESPACE test_tempTEMPFILE /opt/oradata/test_temp.dbfSIZE 32MAUTOEXTEND ONNEXT 32M MAXSIZE 2048MEXTENT MANAGEMENT LOCAL;二、二、创创建用建用户户表空表空间间sql CREATE TABLESPACE test_dataLOGGINGDATAFILE /opt
2、/oradata/test_data.dbfSIZE 32MAUTOEXTEND ONNEXT 32M MAXSIZE 2048MEXTENT MANAGEMENT LOCAL;sql select tablespace_name,block_size,extent_management,segment_space_managementfrom dba_tablespaceswhere tablespce_name like USER%;三、三、还还原表空原表空间间sql create undo tablespace user01_undodatafile /u01/oracle/app/or
3、acle/user01_undo.dbfsize 20M;sql select tablespace_name,block_size,extent_management,segment_space_managementfrom dba_tablespacesfrom tablespace_name like user01_%;sql select tablespace_name,status,contentsfrom dba_tablespacesfrom tablespace_name like user01_%;四、四、 创创建用建用户户并制定表空并制定表空间间sql CREATE USE
4、R username IDENTIFIED BY passwordDEFAULT TABLESPACE TEST_DATATEMPORARY TABLESPACE TEST_TEMP;sql GRANT role TO username;五、五、查查看所有用看所有用户户sql SELECT * FROM DBA_USERS;sql SELECT * FROM ALL_USERS;sql SELECT * FROM USER_USERS;六、六、查查看用看用户户 对对象或角色象或角色权权限限sql SELECT * FROM DBA_TAB_PRIVS;sql SELECT * FROM ALL
5、_TAB_PRIVS;sql SELECT * FROM USER_TAB_PRIVS;七、七、查查看所有角色看所有角色sql SELECT * FROM DBA_ROLES;八、八、查查看用看用户户或角色所或角色所拥拥有的角色有的角色sql SELECT * FROM DBA_ROLE_PRIVS;sql SELECT * FROM USER_ROLE_PRIVS;九、表空九、表空间间脱机脱机sql select tablespace_name,status,contentsfrom dba_tablespaceswhere tablespce_name like user_%;sql co
6、l name for a55sql select file#,name,statusfrom v$datafilewhere file# =8;设置脱机状态sql alter tablespace user01 offline;sql select tablespace_name,status,contentsfrom dba_tablespaceswhere tablespce_name like user01_%;sql select file#,name,statusfrom v$datafilewhere file# = 8;设置联机状态sql alter tablespace use
7、r01 online;十一、只十一、只读读表空表空间间设置只读表空间sql alter tablespace user01 read only;sql select tablespce_name,status,contentsfrom dba_tablespaceswhere tablespace_name like user_%;可读可写sql alter tablespace user01 read write;sql select tablespace_name,status,contentsfrom dba_tablespacewhere tablespace_name like us
8、er%;十二、改十二、改变变表空表空间间的存的存储设储设置置sql alter tablespace user01 minimum extent 100K;sql alter tablespace user01default storage ( initial 100 k next 100 k maxextents 200);sql set line 120sql col tablespace_name for a15sql select tablespace_name,initial_extent,next_extent,max_extents,pct_increase,min_extent
9、sfrom dba_tablespaceswhere tablespace_name like user01%;十三、重置表空十三、重置表空间间大小大小sql col file_name for a40sql set line 100sql col tablespace_name for a15sql select file_id,tablespace_name,file_name,autoextensiblefrom dba_data_fileswhere file_id = 8order by file_id;sql alter database datafile autoextend o
10、nnext 1M;sql select file_id,tablespace_name,file_name,autoextensiblefrom dba_data_fileswhere file_id = 8order by file_id;十四、手工重置数据文件的大小十四、手工重置数据文件的大小sql select file_id,file_name,tablespace_name,bytes/(1024*1024) MBfrom dba_data_fileswhere tablespace_name LIKE USERS01%order by tablespace_name;sql alt
11、er database datafile /u01/oracle/app/oracle/oradata/db243/use01.dbf resize 50M;sql select file_id,file_name,tablespace_name,bytes/(1024*1024)MBfrom dba_data_fileswhere tablespace_name like %USE%order by tablespace_name;sql alter tablespace use01add datafile /u01/oracle/app/oracle/oradata/db243/use01
12、_a.dbfsize 30M;sql select file_id,file_name,tablespace_name,bytes/(1024*1024)MBfrom dba_data_fileswhere tablespace_name like %USE%order by tablespace_name;十五、移十五、移动动数据文件的方法数据文件的方法(一)、移(一)、移动动可以脱机的表空可以脱机的表空间间# sqlplus / as sysdbasql col file_name for a45sql set line 120#查看数据库中数据文件的分布情况sql select file
13、_id,file_name,tablespace_namefrom dba_data_fileswhere file_name like %ORADATA%order by file_name;# 查看数据库表空间的状态sql select tablespace_name,status,contentsfrom dba_tablespaceswhere tablespace_name not like %USE%;# 使表空间脱机sql alter tablespace use01 offline;# 查看更改有没有成功sql select tablespace_name,status,con
14、tentsfrom dba_tablespaceswhere tablespace_name not like %USE%;# CP 数据文件# cp /u01/oracle/app/oracle/oradata/db243/use01.dbf /u01/oracle/app/oradata#使用命令来重新命名表空间所对应的数据文件名sql alter tablespace use01 renamedatafile /u01/oracle/app/oracle/oradata/db243/use01.dbfto /u01/oracle/app/oradata/use01.dbf;#表空间联机s
15、ql alter tablespace use01 online;(二)、移(二)、移动动系系统统表空表空间间Sql shutdown immediatesql startup mountsql host cp /u01/oracle/app/oracle/oradata/db243/system01.dbf /u01/oracle/app/oradatasql alter database renamefile /u01/oracle/app/oracle/oradata/sb243/system01.dbfto /u01/oracle/app/oradata/system01.dbf;sq
16、l alter database open;sql select tablespace_name,status,contentsfrom dba_tablespaces;sql select file_id,file_name,tablespace_namefrom dba_data_files;十六、迁移数据字典和本地管理的表空十六、迁移数据字典和本地管理的表空间间Sql connect sys/wuzihao as sysdba;sql show user;#查看哪些表空间是数据字典管理的sql select tablespace_name,block_size,extent_management,segment_space_management,min_extentsfrom dba_tablespaceswhere tablespac