Oracle数据库管理 DBA必会知识点(一)

2014-11-24 17:51:00 · 作者: · 浏览: 3



oracle重命名数据文件的名字
SQL> alter tablespace aaa offline;
Tablespace altered.
SQL> select ts#,name from v$tablespace;
TS# NAME
---------- ------------------------------
0 SYSTEM
1 SYSAUX
2 UNDOTBS1
4 USERS
3 TEMP
6 EXAMPLE
7 YUANLEI
8 AAA
SQL> select ts#,file#,name,status from v$datafile;
TS# FILE# NAME STATUS
---------- ---------- --------------------------------------------- -------
0 1 /u01/app/oracle/oradata/orcl/system01.dbf SYSTEM
1 2 /u01/app/oracle/oradata/orcl/sysaux01.dbf ONLINE
2 3 /u01/app/oracle/oradata/orcl/undotbs01.dbf ONLINE
4 4 /u01/app/oracle/oradata/orcl/users01.dbf ONLINE
6 5 /u01/app/oracle/oradata/orcl/example01.dbf ONLINE
8 6 /u01/app/oracle/oradata/orcl/bbb01.dbf OFFLINE
SQL> host rename /u01/app/oracle/oradata/orcl/bbb01.dbf aaa01.dbf;
[oracle@oracle11gR2 orcl]$ pwd
/u01/app/oracle/oradata/orcl



[oracle@oracle11gR2 orcl]$ cp bbb01.dbf aaa01.dbf
[oracle@oracle11gR2 orcl]$ ls
aaa01.dbf example01.dbf redo03.log temp01.dbf yuanlei01.dbf
bbb01.dbf redo01.log sysaux01.dbf undotbs01.dbf
control01.ctl redo02.log system01.dbf users01.dbf



SQL> alter database rename file '/u01/app/oracle/oradata/orcl/bbb01.dbf' to '/u01/app/oracle/oradata/orcl/aaa01.dbf';
Database altered.



SQL> alter tablespace aaa online;
Tablespace altered.



SQL> select ts#,file#,name,status from v$datafile;
TS# FILE# NAME STATUS
---------- ---------- --------------------------------------------- -------
0 1 /u01/app/oracle/oradata/orcl/system01.dbf SYSTEM
1 2 /u01/app/oracle/oradata/orcl/sysaux01.dbf ONLINE
2 3 /u01/app/oracle/oradata/orcl/undotbs01.dbf ONLINE
4 4 /u01/app/oracle/oradata/orcl/users01.dbf ONLINE
6 5 /u01/app/oracle/oradata/orcl/example01.dbf ONLINE
8 6 /u01/app/oracle/oradata/orcl/aaa01.dbf ONLINE
6 rows selected.
重命名成功



-----创建临时表空间
SQL> create temporary tablespace test_temp
tempfile '/u01/app/oracle/oradata/orcl/test_temp.dbf' size 10M
autoextend on next 10M maxsize 100M extent management local;



------创建用户表空间并制定用户表空间
SQL> create temporary tablespace test_temp tempfile '/u01/app/oracle/oradata/orcl/test_temp.dbf' size 10M autoextend on next 10M maxsize 100M extent management local;
Tablespace created.
SQL> create tablespace test_data logging datafile '/u01/app/oracle/oradata/orcl/test_data.dbf'
2 size 10M autoextend on next 20M maxsize 100M extent management local;
Tablespace created.
SQL> create user yuanlei identified by leiyuan default tablespace test_data temporary tablespace test_temp;
User created.



------查看所有用户
SELECT * FROM DBA_USERS;



-----查看用户所在的默认和临时表空间,后面可跟where 条件
SQL> select username,default_tablespace,temporary_tablespace from dba_users;



-----修改用户的默认和临时表空间
SQL> alter user yuanlei default tablespace users;
User altered.
SQL> alter user yuanlei temporary tablespace temp;
User altered.



----限定用户在表空间上的使用配额
SQL> alter user yuanlei quota 10M on users;
User altered.
SQL> alter user yuanlei quota unlimited on users quota 1M on example;
User altered.



----查看用户的表空间配额限制 可加条件
SQL> select * from dba_ts_quotas;



TABLESPACE_NAME USERNAME BYTES MAX_BYTES BLOCKS MAX_BLOCKS DRO
----------------------