Oracle 重命名数据文件
2014-11-25 18:01
399 查看
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Oracle 重命名数据文件的两种方法:ALTER TABLESPACE
RENAME DATAFILE和ALTER DATABASE RENAME FILE
ALTER DATABASE RENAME FILE 'old_name' to 'new_name'
ALTER TABLESPACE tablespace_name RENAME DATAFILE
'old_name' TO 'new_name'
通过这两种方法重命名数据文件必须保证目标文件存在(The
operating system files continue to
exist),数据库在open状态下重命名数据文件必须保证要重命名的数据文件所在的表空间处于offline的状态,由于在open状态下system和sysaux表空间不能够被offline,所以在open状态只能重命名除去system和sysaux之外的数据文件。
ALTER DATABASE RENAME FILE
不仅仅可以重命名数据文件,同样可以重命名tempfiles,
or redo log file
重命名数据文件示例如下:
SQL> select file_name,tablespace_name,status from
dba_data_files;
FILE_NAME
TABLESPACE_NAME
STATUS
--------------------------------------------------------------
------------------------------ ---------
/u01/dbabc.net/pass/users01.dbf
USERS
AVAILABLE
/u01/dbabc.net/pass/sysaux01.dbf
SYSAUX
AVAILABLE
/u01/dbabc.net/pass/undotbs01.dbf
UNDOTBS1
AVAILABLE
/u01/dbabc.net/pass/system01.dbf
SYSTEM
AVAILABLE
/u01/dbabc.net/pass/example01.dbf
EXAMPLE
AVAILABLE
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_passt_6dlc02ws_.dbf
PASST
AVAILABLE
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_tp_6dlc7pd7_.dbf
TP
AVAILABLE
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_users1_6dlccg3l_.dbf
USERS1
AVAILABLE
/u01/dbabc.net/dbs/hr_tbs01.dbf
HR_TBS
AVAILABLE
/u01/dbabc.net/dbs/testdefault01.dbf
TEST_DEFAULT
AVAILABLE
10 rows selected
SQL> 重命名PASST
tablespace下的
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_passt_6dlc02ws_.dbf的数据文件
1、首先将PASST tablespace offline
SQL> alter tablespace passt
offline;
Tablespace altered
2、重命名数据文件(OS)
[dbabc.net]cd /dbabc.net/pass/passt/omf/PASS/datafile
[dbabc.net]mv o1_mf_passt_6dlc02ws_.dbf
/dbabc.net/pass/passt_01.dbf
[dbabc.net]cd /dbabc.net/pass/
[dbabc.net]ll passt_*
-rw-r----- 1 oracle oinstall 104865792 Nov 5
08:38 passt_01.dbf
3、ALTER TABLESPACE tablespace_name RENAME ‘old_name’ to
‘new_name’
SQL> ALTER TABLESPACE passt RENAME DATAFILE
'/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_passt_6dlc02ws_.dbf'
TO
'/dbabc.net/pass/passt_01.dbf';
Tablespace altered
4、将表空间online
SQL> alter tablespace passt
online;
Tablespace altered
5、确认一下
SQL> select file_name,tablespace_name,status from
dba_data_files;
FILE_NAME
TABLESPACE_NAME
STATUS
--------------------------------------------------------------
------------------------------ ---------
/u01/dbabc.net/pass/users01.dbf
USERS
AVAILABLE
/u01/dbabc.net/pass/sysaux01.dbf
SYSAUX
AVAILABLE
/u01/dbabc.net/pass/undotbs01.dbf
UNDOTBS1
AVAILABLE
/u01/dbabc.net/pass/system01.dbf
SYSTEM
AVAILABLE
/u01/dbabc.net/pass/example01.dbf
EXAMPLE
AVAILABLE
/dbabc.net/pass/passt_01.dbf
PASST
AVAILABLE
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_tp_6dlc7pd7_.dbf
TP
AVAILABLE
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_users1_6dlccg3l_.dbf
USERS1
AVAILABLE
/u01/dbabc.net/dbs/hr_tbs01.dbf
HR_TBS
AVAILABLE
/u01/dbabc.net/dbs/testdefault01.dbf
TEST_DEFAULT
AVAILABLE
10 rows selected
SQL> 以上是通过ALTER
TABLESPACE RENAME的用法。
下面示例 ALTER DATABASE 重命名的用法。
以TP tablespace为例
1、offline tablespace TP
SQL> alter tablespace tp
offline;
Tablespace altered
2、mv os file of TP tablespace
[dbabc.net]mv
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_tp_6dlc7pd7_.dbf
/dbabc.net/pass/tp_01.dbf
3、ALTER DATABASE RENAME FILE
SQL> ALTER DATABASE RENAME FILE
'/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_tp_6dlc7pd7_.dbf' to
'/dbabc.net/pass/tp_01.dbf';
Database altered
4、online tablespace TP
SQL> alter tablespace tp
online;
Tablespace altered
5、check
SQL> select file_name,tablespace_name,status from
dba_data_files;
FILE_NAME
TABLESPACE_NAME
STATUS
--------------------------------------------------------------
------------------------------ ---------
/u01/dbabc.net/pass/users01.dbf
USERS
AVAILABLE
/u01/dbabc.net/pass/sysaux01.dbf
SYSAUX
AVAILABLE
/u01/dbabc.net/pass/undotbs01.dbf
UNDOTBS1
AVAILABLE
/u01/dbabc.net/pass/system01.dbf
SYSTEM
AVAILABLE
/u01/dbabc.net/pass/example01.dbf
EXAMPLE
AVAILABLE
/dbabc.net/pass/passt_01.dbf
PASST
AVAILABLE
/dbabc.net/pass/tp_01.dbf
TP
AVAILABLE
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_users1_6dlccg3l_.dbf
USERS1
AVAILABLE
/u01/dbabc.net/dbs/hr_tbs01.dbf
HR_TBS
AVAILABLE
/u01/dbabc.net/dbs/testdefault01.dbf
TEST_DEFAULT
AVAILABLE
10 rows selected
SQL> 注:通过 ALTER DATABASE
RENAME FILE 在重命名redo file的时候不需要offline
直接执行就ok了。
SQL> alter database rename file
'/u01/dbabc.net/pass/redo03.log' to
'/u01/dbabc.net/pass/redo03_mv.log';
Database altered
Oracle 重命名数据文件的两种方法:ALTER TABLESPACE
RENAME DATAFILE和ALTER DATABASE RENAME FILE
ALTER DATABASE RENAME FILE 'old_name' to 'new_name'
ALTER TABLESPACE tablespace_name RENAME DATAFILE
'old_name' TO 'new_name'
通过这两种方法重命名数据文件必须保证目标文件存在(The
operating system files continue to
exist),数据库在open状态下重命名数据文件必须保证要重命名的数据文件所在的表空间处于offline的状态,由于在open状态下system和sysaux表空间不能够被offline,所以在open状态只能重命名除去system和sysaux之外的数据文件。
ALTER DATABASE RENAME FILE
不仅仅可以重命名数据文件,同样可以重命名tempfiles,
or redo log file
重命名数据文件示例如下:
SQL> select file_name,tablespace_name,status from
dba_data_files;
FILE_NAME
TABLESPACE_NAME
STATUS
--------------------------------------------------------------
------------------------------ ---------
/u01/dbabc.net/pass/users01.dbf
USERS
AVAILABLE
/u01/dbabc.net/pass/sysaux01.dbf
SYSAUX
AVAILABLE
/u01/dbabc.net/pass/undotbs01.dbf
UNDOTBS1
AVAILABLE
/u01/dbabc.net/pass/system01.dbf
SYSTEM
AVAILABLE
/u01/dbabc.net/pass/example01.dbf
EXAMPLE
AVAILABLE
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_passt_6dlc02ws_.dbf
PASST
AVAILABLE
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_tp_6dlc7pd7_.dbf
TP
AVAILABLE
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_users1_6dlccg3l_.dbf
USERS1
AVAILABLE
/u01/dbabc.net/dbs/hr_tbs01.dbf
HR_TBS
AVAILABLE
/u01/dbabc.net/dbs/testdefault01.dbf
TEST_DEFAULT
AVAILABLE
10 rows selected
SQL> 重命名PASST
tablespace下的
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_passt_6dlc02ws_.dbf的数据文件
1、首先将PASST tablespace offline
SQL> alter tablespace passt
offline;
Tablespace altered
2、重命名数据文件(OS)
[dbabc.net]cd /dbabc.net/pass/passt/omf/PASS/datafile
[dbabc.net]mv o1_mf_passt_6dlc02ws_.dbf
/dbabc.net/pass/passt_01.dbf
[dbabc.net]cd /dbabc.net/pass/
[dbabc.net]ll passt_*
-rw-r----- 1 oracle oinstall 104865792 Nov 5
08:38 passt_01.dbf
3、ALTER TABLESPACE tablespace_name RENAME ‘old_name’ to
‘new_name’
SQL> ALTER TABLESPACE passt RENAME DATAFILE
'/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_passt_6dlc02ws_.dbf'
TO
'/dbabc.net/pass/passt_01.dbf';
Tablespace altered
4、将表空间online
SQL> alter tablespace passt
online;
Tablespace altered
5、确认一下
SQL> select file_name,tablespace_name,status from
dba_data_files;
FILE_NAME
TABLESPACE_NAME
STATUS
--------------------------------------------------------------
------------------------------ ---------
/u01/dbabc.net/pass/users01.dbf
USERS
AVAILABLE
/u01/dbabc.net/pass/sysaux01.dbf
SYSAUX
AVAILABLE
/u01/dbabc.net/pass/undotbs01.dbf
UNDOTBS1
AVAILABLE
/u01/dbabc.net/pass/system01.dbf
SYSTEM
AVAILABLE
/u01/dbabc.net/pass/example01.dbf
EXAMPLE
AVAILABLE
/dbabc.net/pass/passt_01.dbf
PASST
AVAILABLE
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_tp_6dlc7pd7_.dbf
TP
AVAILABLE
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_users1_6dlccg3l_.dbf
USERS1
AVAILABLE
/u01/dbabc.net/dbs/hr_tbs01.dbf
HR_TBS
AVAILABLE
/u01/dbabc.net/dbs/testdefault01.dbf
TEST_DEFAULT
AVAILABLE
10 rows selected
SQL> 以上是通过ALTER
TABLESPACE RENAME的用法。
下面示例 ALTER DATABASE 重命名的用法。
以TP tablespace为例
1、offline tablespace TP
SQL> alter tablespace tp
offline;
Tablespace altered
2、mv os file of TP tablespace
[dbabc.net]mv
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_tp_6dlc7pd7_.dbf
/dbabc.net/pass/tp_01.dbf
3、ALTER DATABASE RENAME FILE
SQL> ALTER DATABASE RENAME FILE
'/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_tp_6dlc7pd7_.dbf' to
'/dbabc.net/pass/tp_01.dbf';
Database altered
4、online tablespace TP
SQL> alter tablespace tp
online;
Tablespace altered
5、check
SQL> select file_name,tablespace_name,status from
dba_data_files;
FILE_NAME
TABLESPACE_NAME
STATUS
--------------------------------------------------------------
------------------------------ ---------
/u01/dbabc.net/pass/users01.dbf
USERS
AVAILABLE
/u01/dbabc.net/pass/sysaux01.dbf
SYSAUX
AVAILABLE
/u01/dbabc.net/pass/undotbs01.dbf
UNDOTBS1
AVAILABLE
/u01/dbabc.net/pass/system01.dbf
SYSTEM
AVAILABLE
/u01/dbabc.net/pass/example01.dbf
EXAMPLE
AVAILABLE
/dbabc.net/pass/passt_01.dbf
PASST
AVAILABLE
/dbabc.net/pass/tp_01.dbf
TP
AVAILABLE
/dbabc.net/pass/passt/omf/PASS/datafile/o1_mf_users1_6dlccg3l_.dbf
USERS1
AVAILABLE
/u01/dbabc.net/dbs/hr_tbs01.dbf
HR_TBS
AVAILABLE
/u01/dbabc.net/dbs/testdefault01.dbf
TEST_DEFAULT
AVAILABLE
10 rows selected
SQL> 注:通过 ALTER DATABASE
RENAME FILE 在重命名redo file的时候不需要offline
直接执行就ok了。
SQL> alter database rename file
'/u01/dbabc.net/pass/redo03.log' to
'/u01/dbabc.net/pass/redo03_mv.log';
Database altered
相关文章推荐
- ORACLE 11G 数据文件头格式
- ORACLE:实例化 EM 配置文件时出错…
- oracle 命名规范
- Oracle 中常用数据字典大总结…
- oracle 提取数据 随机排序
- Oracle date类型数据
- ios 将数据写入到文件
- ORACLE 参数文件
- 通过cat 数据文件来合并 myisam表
- oracle 11g 添加控制文件
- oracle数据文件"*.dbf"的转移
- RMAN 恢复实际操作(模拟数据文件…
- Oracle 如何修改列的数据类型
- oracle 日志文件管理
- Oracle 参数文件 spfile  pfile
- ORACLE 数据字典
- ibatis 配置文件及对应数据的格式…
- 转移oracle数据文件"*.dbf"
- Oracle Data Guard_ 主库重命名数据文件
- 【Oracle】重命名数据文件