利用datafile copy將資料檔案重新命名,datafilecopy

來源:互聯網
上載者:User

利用datafile copy將資料檔案重新命名,datafilecopy

思路:

o 利用RMAN對資料檔案做copy

o 將資料檔案offline

o switch檔案名稱,這一步將更改控制檔案中資料檔案對應的檔案名稱

o recover資料檔案

o 將資料檔案online,恢複生產

注:也可以利用這種思路做DATABASE COPY,然後做SWITCH DATABASE,遷移資料庫...

 

實驗過程如下:

======================================

SQL> archive log list;
Database log mode        Archive Mode
Automatic archival        Enabled
Archive destination        /home/oracle/arch
Oldest online log sequence     63
Next log sequence to archive   65
Current log sequence        65

RMAN> report schema;

using target database control file instead of recovery catalog
Report of database schema

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    700      SYSTEM               ***     /u01/app/oracle/oradata/ora10g/system01.dbf
2    700      UNDOTBS1             ***     /u01/app/oracle/oradata/ora10g/undotbs01.dbf
3    260      SYSAUX               ***     /u01/app/oracle/oradata/ora10g/sysaux01.dbf
4    5        USERS                ***     /u01/app/oracle/oradata/ora10g/users01.dbf
5    5        USERS                ***     /u01/app/oracle/oradata/ora10g/users02.dbf      <<<<<<<<計劃將5號資料檔案重新命名

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    30       TEMP                 32767       /u01/app/oracle/oradata/ora10g/temp01.dbf

RMAN> backup as copy datafile 5 format '/u01/app/oracle/oradata/ora10g/users02_new.dbf';

Starting backup at 05-FEB-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=146 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/u01/app/oracle/oradata/ora10g/users02.dbf
output filename=/u01/app/oracle/oradata/ora10g/users02_new.dbf tag=TAG20150205T225207 recid=1 stamp=870907927
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 05-FEB-15

SQL> alter database datafile 5 offline;

Database altered.
SQL> recover datafile 5;
Media recovery complete.
SQL> alter database datafile 5 online;

Database altered.

RMAN> report schema;

Report of database schema

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    700      SYSTEM               ***     /u01/app/oracle/oradata/ora10g/system01.dbf
2    700      UNDOTBS1             ***     /u01/app/oracle/oradata/ora10g/undotbs01.dbf
3    260      SYSAUX               ***     /u01/app/oracle/oradata/ora10g/sysaux01.dbf
4    5        USERS                ***     /u01/app/oracle/oradata/ora10g/users01.dbf
5    5        USERS                ***     /u01/app/oracle/oradata/ora10g/users02_new.dbf       <<<<<<<<<<<<<<<<<<檔案名稱已更換

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    30       TEMP                 32767       /u01/app/oracle/oradata/ora10g/temp01.dbf

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.