实验简介:PDB基于时间点的恢复,PDB1_WHS恢复到之前的时间点,但不影响其他的PDB
创建实验数据
[root@cat1 ~]# su - oracle
Last login: Mon May 2 18:19:30 CST 2005 on pts/0
[oracle@cat1 ~]$ export ORACLE_SID=whs11
[oracle@cat1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Tue May 3 15:51:40 2005
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1_WHS READ WRITE NO
4 PDB2_WHS MOUNTED
5 PDB3_WHS MOUNTED
SQL> alter session set container=PDB1_WHS;
Session altered.
SQL> create table test as select * from dba_tables;
Table created.
SQL> select count(*) from test;
COUNT(*)
----------
2177
SQL> select timestamp_to_scn(sysdate) from dual;
TIMESTAMP_TO_SCN(SYSDATE)
-------------------------
49827779
SQL> truncate table test; <--清空数据
Table truncated.
SQL> select count(*) from test;
COUNT(*)
----------
0
SQL> alter pluggable database PDB1_WHS close immediate;
Pluggable database altered.
SQL> alter session set container=PDB2_WHS;
Session altered.
SQL> startup
Pluggable Database opened.
SQL> create table test as select * from dba_tables;
Table created.
SQL> select count(*) from test;
COUNT(*)
----------
2178
rman恢复PDB1_WHS,不影响PDB2_WHS
[oracle@cat1 ~]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Tue May 3 16:05:06 2005
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: WHS1 (DBID=2406852607)
RMAN> run{
2> set until scn=49827779;
3> restore pluggable database PDB1_WHS;
4> recover pluggable database PDB1_WHS;
5> alter pluggable database PDB1_WHS open resetlogs;
6> }
executing command: SET until clause
Starting restore at 03-MAY-05
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=158 instance=whs11 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00010 to +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/system.274.1057318913
channel ORA_DISK_1: restoring datafile 00011 to +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/sysaux.275.1057318911
channel ORA_DISK_1: restoring datafile 00012 to +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/undotbs1.273.1057318911
channel ORA_DISK_1: restoring datafile 00013 to +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/undo_2.277.1057318927
channel ORA_DISK_1: restoring datafile 00014 to +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/users.278.1057318927
channel ORA_DISK_1: reading from backup piece /rmanbackup/rman0_WHS1_9_20050503
channel ORA_DISK_1: piece handle=/rmanbackup/rman0_WHS1_9_20050503 tag=LEVEL0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 03-MAY-05
Starting recover at 03-MAY-05
current log archived
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 2 is already on disk as file +DATA1/WHS1/ARCHIVELOG/2005_05_03/thread_1_seq_2.296.557280929
archived log for thread 1 with sequence 3 is already on disk as file +DATA1/WHS1/ARCHIVELOG/2005_05_03/thread_1_seq_3.297.557337933
media recovery complete, elapsed time: 00:00:00
Finished recover at 03-MAY-05
Statement processed
验证
PDB1_WHS恢复的truncate前,PDB2_WHS不受影响
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1_WHS READ WRITE NO
4 PDB2_WHS READ WRITE NO
5 PDB3_WHS MOUNTED
SQL> alter session set container=PDB1_WHS;
Session altered.
SQL> select count(*) from test;
COUNT(*)
----------
2177
SQL> alter session set container=PDB2_WHS;
Session altered.
SQL> select count(*) from test;
COUNT(*)
----------
2178