RECOVER DATABASE SKIP TABLESPACE

在一篇文章中看到RECOVER DATABASE SKIP TABLESPACE,可以跳过表空间,也就是可以恢复指定的表空间,那么在已超过了闪回查询的时间,但是需要恢复指定的数据,此时有完整的备份文件,并且数据库用户表空间比较多比较大时,这个命令就很有用了。把备份传到另一台服务器上,然后只用恢复系统表空间、UNDO表空间再加上要恢复数据库的用户表空间就可以了。

做个实验,先将PROD数据库中的scott.t1表清空,scott的默认表空间为users,数据库已开启归档并配置了rman备份,创建新的实例TWO,恢复scott.t1的数据。由于只有一台虚拟机,两个库在同一服务器中,

恢复步骤如下:

1、复制前一天的备份集;

2、在源库创建pfile文件,修改此文件后创建一个新的实例TWO;

3、rman还原指定表空间;

4、rman恢复跳过不需要的表空间;

5、read only数据库,查看数据是否恢复,如未恢复,重复第4步,直到找到数据为止;

Scott.t1已清空,备份集已复制,以下是恢复过程。

1、修改pfile文件,创建新实例。

*.audit_file_dest='/u01/app/oracle/admin/TWO/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oradata/TWO/control01.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='PROD'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=PRODXDB)'
*.nls_territory='CHINA'
*.open_cursors=300
*.pga_aggregate_target=61756748
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=300
*.sga_target=507374182
*.sga_max_size=1073741824
*.undo_tablespace='UNDOTBS1'
*.nls_language='AMERICAN'

创建目录

mkdir /u01/app/oracle/admin/TWO/adump

mkdir /u01/app/oracle/oradata

2、实例TWO启动到nomount状态

[oracle@ora11g ~]$ export ORACLE_SID=TWO

  SQL> startup nomount;
  ORACLE instance started.

  Total System Global Area 1068937216 bytes
  Fixed Size 2260088 bytes
  Variable Size 822084488 bytes
  Database Buffers 239075328 bytes
  Redo Buffers 5517312 bytes

3、rman还原数据库

[oracle@ora11g ~]$ export ORACLE_SID=TWO
[oracle@ora11g ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Nov 19 15:23:18 2021

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PROD (not mounted)

RMAN> restore controlfile from '/home/oracle/RMANBAK/dbbak/ctl_file_qo0ehh33_1_1_20211119';

Starting restore at 19-NOV-21
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oradata/TWO/control01.ctl
Finished restore at 19-NOV-21RMAN> alter database mount;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 11/19/2021 15:26:16
ORA-01102: cannot mount database in EXCLUSIVE mode

这个错误是由于主机上已有一个数据库PROD,在Oracle_home/dbs目录中已存在lkPROD文件,这个文件会阻止两个实例mount同一数据库,查看文件内容只有一句话:
DO NOT DELETE THIS FILE!
db_name是不能更改的,否则会与备份集中控制文件不一致。
那么更改pfile文件,添加db_unique_name=TEST,重新启动数据库到nomount状态后restore。
更改后的pfile文件

*.audit_file_dest='/u01/app/oracle/admin/TWO/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oradata/TWO/control01.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='PROD'
*.db_unique_name='TEST'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=SCPRDXDB)'
*.nls_territory='CHINA'
*.open_cursors=300
*.pga_aggregate_target=61756748
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=300
*.sga_target=507374182
*.sga_max_size=1073741824
*.undo_tablespace='UNDOTBS1'
*.nls_language='AMERICAN'

TWO实例启动到Nomount状态后,发现dbs目录中新生成了lkTEST文件,这个名字是按db_unique_name来的。

[oracle@ora11g dbs]$ ll
total 879972
-rw-r----- 1 oracle oinstall 155098624 Nov 14 03:00 arch1_168_1081291239.dbf
-rw-r----- 1 oracle oinstall      1024 Nov 14 03:00 arch1_169_1081291239.dbf
-rw-r----- 1 oracle oinstall 166820352 Nov 15 03:00 arch1_170_1081291239.dbf
-rw-r----- 1 oracle oinstall      1024 Nov 15 03:00 arch1_171_1081291239.dbf
-rw-r----- 1 oracle oinstall 125941760 Nov 16 03:00 arch1_172_1081291239.dbf
-rw-r----- 1 oracle oinstall      1024 Nov 16 03:00 arch1_173_1081291239.dbf
-rw-r----- 1 oracle oinstall 159354368 Nov 17 03:00 arch1_174_1081291239.dbf
-rw-r----- 1 oracle oinstall      1024 Nov 17 03:00 arch1_175_1081291239.dbf
-rw-r----- 1 oracle oinstall 147319808 Nov 18 03:00 arch1_176_1081291239.dbf
-rw-r----- 1 oracle oinstall      1024 Nov 18 03:00 arch1_177_1081291239.dbf
-rw-r----- 1 oracle oinstall 136742400 Nov 19 03:00 arch1_178_1081291239.dbf
-rw-r----- 1 oracle oinstall      1024 Nov 19 03:00 arch1_179_1081291239.dbf
-rw-rw---- 1 oracle oinstall      1544 Nov 19 15:57 hc_PROD.dat
-rw-rw---- 1 oracle oinstall      1544 Nov 19 17:00 hc_TWO.dat
-rw-r--r-- 1 oracle oinstall      2851 May 15  2009 init.ora
-rw-r--r-- 1 oracle oinstall       586 Nov 19 16:15 initTWO.ora
-rw-r----- 1 oracle oinstall        24 Nov 29  2020 lkPROD
-rw-r----- 1 oracle oinstall        24 Nov 19 16:08 lkTEST
-rw-r----- 1 oracle oinstall      1536 Jul  9 15:36 orapwPROD
-rw-r----- 1 oracle oinstall   9748480 Nov 19 03:00 snapcf_PROD.f
-rw-r----- 1 oracle oinstall      3584 Nov 19 15:58 spfilePROD.ora
[oracle@ora11g ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Nov 19 16:15:29 2021

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PROD (not mounted)

RMAN> alter database mount;

using target database control file instead of recovery catalog
database mounted

RMAN> list backup of controlfile;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
842     Incr 1  1.09M      DISK        00:00:00     18-NOV-21      
        BP Key: 850   Status: AVAILABLE  Compressed: YES  Tag: PROD_LEV1
        Piece Name: /home/oracle/RMANBAK/PROD_lev1_qc0eesn0_1_1_20211118
  Control File Included: Ckp SCN: 8553093      Ckp time: 18-NOV-21

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
845     Full    9.33M      DISK        00:00:02     18-NOV-21      
        BP Key: 853   Status: AVAILABLE  Compressed: NO  Tag: BAK_CTLFILE
        Piece Name: /home/oracle/RMANBAK/ctl_file_qg0eesn3_1_1_20211118
  Control File Included: Ckp SCN: 8553124      Ckp time: 18-NOV-21

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
850     Incr 1  1.09M      DISK        00:00:00     19-NOV-21      
        BP Key: 858   Status: AVAILABLE  Compressed: YES  Tag: PROD_LEV1
        Piece Name: /home/oracle/RMANBAK/PROD_lev1_qk0ehh30_1_1_20211119
  Control File Included: Ckp SCN: 8619449      Ckp time: 19-NOV-21

RMAN> catalog start with '/home/oracle/RMANBAK/dbbak
2> ';

searching for all files that match the pattern /home/oracle/RMANBAK/dbbak

List of Files Unknown to the Database
=====================================
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev0_pq0e9jtj_1_1_20211116
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev0_pr0e9jtj_1_1_20211116
File Name: /home/oracle/RMANBAK/dbbak/arch_pv0e9juq_1_1_20211116
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_q20ec89i_1_1_20211117
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_q30ec89i_1_1_20211117
File Name: /home/oracle/RMANBAK/dbbak/arch_q60ec8b2_1_1_20211117
File Name: /home/oracle/RMANBAK/dbbak/arch_q70ec8b2_1_1_20211117
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_qa0eeslj_1_1_20211118
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_qb0eeslj_1_1_20211118
File Name: /home/oracle/RMANBAK/dbbak/arch_qe0eesn2_1_1_20211118
File Name: /home/oracle/RMANBAK/dbbak/arch_qf0eesn2_1_1_20211118
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_qi0ehh1j_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_qk0ehh30_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/ctl_file_qo0ehh33_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/arch_pu0e9juq_1_1_20211116
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_ql0ehh30_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/arch_qn0ehh32_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_qj0ehh1j_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/arch_qm0ehh32_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/PROD_spfile_qp0ehh35_1_1_20211119

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev0_pq0e9jtj_1_1_20211116
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev0_pr0e9jtj_1_1_20211116
File Name: /home/oracle/RMANBAK/dbbak/arch_pv0e9juq_1_1_20211116
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_q20ec89i_1_1_20211117
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_q30ec89i_1_1_20211117
File Name: /home/oracle/RMANBAK/dbbak/arch_q60ec8b2_1_1_20211117
File Name: /home/oracle/RMANBAK/dbbak/arch_q70ec8b2_1_1_20211117
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_qa0eeslj_1_1_20211118
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_qb0eeslj_1_1_20211118
File Name: /home/oracle/RMANBAK/dbbak/arch_qe0eesn2_1_1_20211118
File Name: /home/oracle/RMANBAK/dbbak/arch_qf0eesn2_1_1_20211118
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_qi0ehh1j_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_qk0ehh30_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/ctl_file_qo0ehh33_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/arch_pu0e9juq_1_1_20211116
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_ql0ehh30_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/arch_qn0ehh32_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/PROD_lev1_qj0ehh1j_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/arch_qm0ehh32_1_1_20211119
File Name: /home/oracle/RMANBAK/dbbak/PROD_spfile_qp0ehh35_1_1_20211119

RMAN> run{
2> sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
3> set until time '2021-11-18 23:00:00';
4> allocate channel ch01 device type disk;
5> allocate channel ch02 device type disk;
6> set newname for datafile  1 to '/u01/app/oradata/TWO/system01.dbf';
7> set newname for datafile  2 to '/u01/app/oradata/TWO/sysaux01.dbf';
8> set newname for datafile  3 to '/u01/app/oradata/TWO/undotbs01.dbf';
9> set newname for datafile  4 to '/u01/app/oradata/TWO/users01.dbf';
10> restore tablespace SYSTEM,SYSAUX,UNDOTBS1,USERS;
11> switch datafile all;
12> release channel ch01;
13> release channel ch02;
14> }

sql statement: alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"

executing command: SET until clause

released channel: ORA_DISK_1
allocated channel: ch01
channel ch01: SID=10 device type=DISK

allocated channel: ch02
channel ch02: SID=247 device type=DISK

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 19-NOV-21

channel ch01: starting datafile backup set restore
channel ch01: specifying datafile(s) to restore from backup set
channel ch01: restoring datafile 00001 to /u01/app/oradata/TWO/system01.dbf
channel ch01: restoring datafile 00003 to /u01/app/oradata/TWO/undotbs01.dbf
channel ch01: reading from backup piece /home/oracle/RMANBAK/PROD_lev0_pr0e9jtj_1_1_20211116
channel ch02: starting datafile backup set restore
channel ch02: specifying datafile(s) to restore from backup set
channel ch02: restoring datafile 00002 to /u01/app/oradata/TWO/sysaux01.dbf
channel ch02: restoring datafile 00004 to /u01/app/oradata/TWO/users01.dbf
channel ch02: reading from backup piece /home/oracle/RMANBAK/PROD_lev0_pq0e9jtj_1_1_20211116
channel ch01: piece handle=/home/oracle/RMANBAK/PROD_lev0_pr0e9jtj_1_1_20211116 tag=PROD_LEV0
channel ch01: restored backup piece 1
channel ch01: restore complete, elapsed time: 00:01:15
channel ch02: piece handle=/home/oracle/RMANBAK/PROD_lev0_pq0e9jtj_1_1_20211116 tag=PROD_LEV0
channel ch02: restored backup piece 1
channel ch02: restore complete, elapsed time: 00:01:15
Finished restore at 19-NOV-21

datafile 1 switched to datafile copy
input datafile copy RECID=23 STAMP=1089046455 file name=/u01/app/oradata/TWO/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=24 STAMP=1089046455 file name=/u01/app/oradata/TWO/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=25 STAMP=1089046455 file name=/u01/app/oradata/TWO/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=26 STAMP=1089046455 file name=/u01/app/oradata/TWO/users01.dbf

released channel: ch01

released channel: ch02

RMAN> run{
2> sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
3> set until time '2021-11-18 23:00:00';
4> allocate channel ch01 device type disk;
5> recover database skip tablespace DATA1,DATA2,BMI,DATA3;
6> switch datafile all;
7> release channel ch01;
8> }

sql statement: alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"

executing command: SET until clause

allocated channel: ch01
channel ch01: SID=10 device type=DISK

Starting recover at 19-NOV-21
channel ch01: starting incremental datafile backup set restore
channel ch01: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /u01/app/oradata/TWO/system01.dbf
destination for restore of datafile 00003: /u01/app/oradata/TWO/undotbs01.dbf
channel ch01: reading from backup piece /home/oracle/RMANBAK/PROD_lev1_q30ec89i_1_1_20211117
channel ch01: piece handle=/home/oracle/RMANBAK/PROD_lev1_q30ec89i_1_1_20211117 tag=PROD_LEV1
channel ch01: restored backup piece 1
channel ch01: restore complete, elapsed time: 00:00:03
channel ch01: starting incremental datafile backup set restore
channel ch01: specifying datafile(s) to restore from backup set
destination for restore of datafile 00002: /u01/app/oradata/TWO/sysaux01.dbf
destination for restore of datafile 00004: /u01/app/oradata/TWO/users01.dbf
channel ch01: reading from backup piece /home/oracle/RMANBAK/PROD_lev1_q20ec89i_1_1_20211117
channel ch01: piece handle=/home/oracle/RMANBAK/PROD_lev1_q20ec89i_1_1_20211117 tag=PROD_LEV1
channel ch01: restored backup piece 1
channel ch01: restore complete, elapsed time: 00:00:03
channel ch01: starting incremental datafile backup set restore
channel ch01: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /u01/app/oradata/TWO/system01.dbf
destination for restore of datafile 00003: /u01/app/oradata/TWO/undotbs01.dbf
channel ch01: reading from backup piece /home/oracle/RMANBAK/PROD_lev1_qb0eeslj_1_1_20211118
channel ch01: piece handle=/home/oracle/RMANBAK/PROD_lev1_qb0eeslj_1_1_20211118 tag=PROD_LEV1
channel ch01: restored backup piece 1
channel ch01: restore complete, elapsed time: 00:00:03
channel ch01: starting incremental datafile backup set restore
channel ch01: specifying datafile(s) to restore from backup set
destination for restore of datafile 00002: /u01/app/oradata/TWO/sysaux01.dbf
destination for restore of datafile 00004: /u01/app/oradata/TWO/users01.dbf
channel ch01: reading from backup piece /home/oracle/RMANBAK/PROD_lev1_qa0eeslj_1_1_20211118
channel ch01: piece handle=/home/oracle/RMANBAK/PROD_lev1_qa0eeslj_1_1_20211118 tag=PROD_LEV1
channel ch01: restored backup piece 1
channel ch01: restore complete, elapsed time: 00:00:03

Executing: alter database datafile 5 offline
Executing: alter database datafile 7 offline
Executing: alter database datafile 6 offline
Executing: alter database datafile 9 offline
Executing: alter database datafile 10 offline
Executing: alter database datafile 8 offline
starting media recovery

archived log for thread 1 with sequence 176 is already on disk as file /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_176_1081291239.dbf
archived log for thread 1 with sequence 177 is already on disk as file /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_177_1081291239.dbf
archived log for thread 1 with sequence 178 is already on disk as file /u01/app/oradata/PROD/redo2.log
archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_176_1081291239.dbf thread=1 sequence=176
archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_177_1081291239.dbf thread=1 sequence=177
archived log file name=/u01/app/oradata/PROD/redo2.log thread=1 sequence=178
media recovery complete, elapsed time: 00:00:06
Finished recover at 19-NOV-21


released channel: ch01

4、检查数据,

[oracle@ora11g ~]$ export ORACLE_SID=PROD
[oracle@ora11g ~]$ sqlplus  / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Nov 19 17:54:29 2021

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SET LINE 222
SQL> select * from scott.t1;

no rows selected

[oracle@ora11g ~]$ export ORACLE_SID=TWO
[oracle@ora11g ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Nov 19 17:54:29 2021

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> select * from t1;
select * from t1
              *
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only


SQL> alter database open read only;

Database altered.

SQL> set line 222
SQL> select * from scott.t1;

     EMPNO ENAME                JOB                       MGR HIREDATE            SAL       COMM     DEPTNO
---------- -------------------- ------------------ ---------- ------------ ---------- ---------- ----------
      1111 JACK                 AAAA                        0                   11111
      7369 SMITH                CLERK                    7902 17-DEC-80           800                    20
      7499 ALLEN                SALESMAN                 7698 20-FEB-81          1600        300         30
      7521 WARD                 SALESMAN                 7698 22-FEB-81          1250        500         30
      7566 JONES                MANAGER                  7839 02-APR-81          2975                    20
      7654 MARTIN               SALESMAN                 7698 28-SEP-81          1250       1400         30
      7698 BLAKE                MANAGER                  7839 01-MAY-81          2850                    30
      7782 CLARK                MANAGER                  7839 09-JUN-81          2450                    10
      7788 SCOTT                ANALYST                  7566 19-APR-87          3000                    20
      7839 KING                 PRESIDENT                   0 17-NOV-81          5000                    10
      7844 TURNER               SALESMAN                 7698 08-SEP-81          1500          0         30

     EMPNO ENAME                JOB                       MGR HIREDATE            SAL       COMM     DEPTNO
---------- -------------------- ------------------ ---------- ------------ ---------- ---------- ----------
      7876 ADAMS                CLERK                    7788 23-MAY-87          1100                    20
      7900 JAMES                CLERK                    7698 03-DEC-81           950                    30
      7902 FORD                 ANALYST                  7566 03-DEC-81          3000                    20
      7934 MILLER               CLERK                    7782 12-OCT-21          1300                    10

15 rows selected.

在TWO实例中数据已恢复,余下的事就好处理了,resetlogs开库后,根据数据量的大小可以采取dblink及数据泵的方式来取回数据。

再来对比一下新旧实例的名字。

SQL> show parameter name;

NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- ------------------------------
cell_offloadgroup_name               string
db_file_name_convert                 string
db_name                              string                 PROD
db_unique_name                       string                 PROD
global_names                         boolean                FALSE
instance_name                        string                 PROD
lock_name_space                      string
log_file_name_convert                string
processor_group_name                 string
service_names                        string                 PROD

SQL> show parameter name;     

NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- ------------------------------
cell_offloadgroup_name               string
db_file_name_convert                 string
db_name                              string                 PROD
db_unique_name                       string                 TEST
global_names                         boolean                FALSE
instance_name                        string                 TWO
lock_name_space                      string
log_file_name_convert                string
processor_group_name                 string
service_names                        string                 TEST

实验中执行的RESTORE与RECOVER命令

run{
sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
set until time '2021-11-18 23:00:00';
allocate channel ch01 device type disk;
allocate channel ch02 device type disk;
set newname for datafile  1 to '/u01/app/oradata/TWO/system01.dbf';
set newname for datafile  2 to '/u01/app/oradata/TWO/sysaux01.dbf';
set newname for datafile  3 to '/u01/app/oradata/TWO/undotbs01.dbf';
set newname for datafile  4 to '/u01/app/oradata/TWO/users01.dbf';
restore tablespace SYSTEM,SYSAUX,UNDOTBS1,USERS;
switch datafile all;
release channel ch01;
release channel ch02;
}


run{
sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
set until time '2021-11-18 23:00:00';
allocate channel ch01 device type disk;
recover database skip tablespace DATA1,DATA2,BMI,DATA3;
switch datafile all;
release channel ch01;
}
原文地址:https://www.cnblogs.com/historynote/p/15578634.html