您的位置:首页 > 数据库

『文件管理』在数据库打开时对非系统表空间的数据文件改名

2009-09-01 15:09 429 查看
 如何在数据库打开时对非系统表空间的数据文件改名,参考下面步骤: 1. 确定数据文件状态
select file_name, status
      from dba_data_files
        where tablespace_name ='tablespace_name';
2. 将表空间置为read-only(时间可能会很长,比重启数据库的时间还长)
    alter tablespace tablespace_name read only;
3. 确定表空间状态为read-only
select tablespace_name, status
      from dba_tablespaces 
        where tablespace_name = 'tablespace_name';
4. 用操作系统命令将数据文件拷贝为新的文件名,确认大小一样
5. 将表空间offline(这时用户就不能访问这个表空间了)
  alter tablespace tablespace_name offline;
6. 修改控制文件中的相应记录
     alter database rename file 
        '/full_path_of_old_location/and_datafile_name.dbf'
             to
        '/full_path_of_new_location/and_datafile_name.dbf';
7. 将表空间online
    alter tablespace tablespace_name online;
8. 将表空间置回为read-write
   alter tablespace tablespace_name read write;
9. 备份控制文件
    alter database backup controlfile to trace;
10. 在操作系统上删除原来的数据文件
 
说明:
  1. 将表空间先置为read-only,是让用户不能访问(read)的时间尽量少点(少的时间为拷贝文件所需的时间)
  2. 如果是standby环境,对standby的恢复没有影响,如果要保持一致的话,mount standby后用cp然后alter database rename file ..... 即可。 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐