RMAN table recovery (12c new feature)

Cyrille Modiano
Latest posts by Cyrille Modiano (see all)

Before oracle 12c, recover a table from loss or corruption was a difficult affair.
Most of the time you notice that the table is lost or corrupted too late to use the flashback technology and then the only way to go is to duplicate your database to a time the table was still valid, export this table and reimport it in your production database. That was a long drawn out affair.
Oracle 12c still procede the same way, it creates an auxiliary database with just the needed tablespace(s) containing the table to restore, export the table using datapump and reimport it to the database. All these steps are now automated. This feature is only available in Enterprise Edition as for the Tablespace Point in time recovery.

Recover a table with RMAN

As for any RMAN recovery you can restore your table by specifying :

  • UNTIL SCN
  • UNTIL SEQUENCE
  • UNTIL TIME


For the exemple we will simulate the corruption of a table and try to restore it with RMAN.
First, lets create our test table:

SQL> create user demo identified by demo;

User created.

SQL> grant connect, resource to demo;

Grant succeeded.

SQL> alter user demo quota unlimited on USERS;

User altered.

SQL> create table demo.test(id number, text varchar2(50));

Table created.

SQL> begin
  2  for i in 1..5000 loop
  3  insert into demo.test values (i,'this is a test');
  4   end loop;
  5  end;
  6  /

PL/SQL procedure successfully completed.

SQL> commit;

Commit complete.

Now we will query the current scn to be able to restore our table before the corruption:

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    1756563

I will Now just alter some rows to simulate the corruption:

SQL> update demo.test set text='this is the corruption' where id in (1,50,610);

3 rows updated.

SQL> commit;

Commit complete.

SQL> select text from demo.test where id in (1,50,610);

TEXT
--------------------------------------------------
this is the corruption
this is the corruption
this is the corruption

First step before trying to restore our table is to take a backup of our database.

RMAN> backup database include current controlfile plus archivelog delete input;

Starting backup at 25-FEB-14
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=13 RECID=9 STAMP=840463382
input archived log thread=1 sequence=14 RECID=10 STAMP=840463417
channel ORA_DISK_1: starting piece 1 at 25-FEB-14
channel ORA_DISK_1: finished piece 1 at 25-FEB-14
piece handle=/u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_annnn_TAG20140225T140337_9jst89xj_.bkp tag=TAG20140225T140337 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/app/oracle/fast_recovery_area/DB12CE/archivelog/2014_02_25/o1_mf_1_13_9jst76h4_.arc RECID=9 STAMP=840463382
archived log file name=/u01/app/oracle/fast_recovery_area/DB12CE/archivelog/2014_02_25/o1_mf_1_14_9jst89nv_.arc RECID=10 STAMP=840463417
Finished backup at 25-FEB-14

Starting backup at 25-FEB-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/DB12CE/datafile/o1_mf_system_9jsr6jd1_.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/DB12CE/datafile/o1_mf_sysaux_9jsr44wb_.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/DB12CE/datafile/o1_mf_undotbs1_9jsr96vn_.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/DB12CE/datafile/o1_mf_users_9jsr95qd_.dbf
channel ORA_DISK_1: starting piece 1 at 25-FEB-14
channel ORA_DISK_1: finished piece 1 at 25-FEB-14
piece handle=/u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_nnndf_TAG20140225T140339_9jst8cg6_.bkp tag=TAG20140225T140339 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 25-FEB-14
channel ORA_DISK_1: finished piece 1 at 25-FEB-14
piece handle=/u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_ncsnf_TAG20140225T140339_9jst9skn_.bkp tag=TAG20140225T140339 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-FEB-14

Starting backup at 25-FEB-14
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=15 RECID=11 STAMP=840463466
channel ORA_DISK_1: starting piece 1 at 25-FEB-14
channel ORA_DISK_1: finished piece 1 at 25-FEB-14
piece handle=/u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_annnn_TAG20140225T140426_9jst9tyh_.bkp tag=TAG20140225T140426 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/app/oracle/fast_recovery_area/DB12CE/archivelog/2014_02_25/o1_mf_1_15_9jst9tqd_.arc RECID=11 STAMP=840463466
Finished backup at 25-FEB-14

Here we go, lets try to recover our table, here is the script I will use:

RECOVER TABLE 'DEMO'.'TEST' 
UNTIL SCN 1753839
AUXILIARY DESTINATION '/u01/app/oracle/oradata_aux'  
REMAP TABLE 'DEMO'.'TEST':'TEST_BEFORE';

Basically what will this script do ? it will create a clone of my database to the scn 1756563 (the scn before I made the corruption). The files of the cloned database will be placed in ‘/u01/app/oracle/oradata_aux’ and the table will be reimported in my database using the new name TEST_BEFORE.

DBA Oracle Montrรฉal

Starting recover at 25-FEB-14
using channel ORA_DISK_1
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time

List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1

Creating automatic instance, with SID='noya'

initialization parameters used for automatic instance:
db_name=DB12CE
db_unique_name=noya_pitr_DB12CE
compatible=12.1.0.0.0
db_block_size=8192
db_files=200
sga_target=1G
processes=80
diagnostic_dest=/u01/app/oracle
db_create_file_dest=/u01/app/oracle/oradata_aux
log_archive_dest_1='location=/u01/app/oracle/oradata_aux'
#No auxiliary parameter file used

starting up automatic instance DB12CE

Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2296576 bytes
Variable Size                281019648 bytes
Database Buffers             780140544 bytes
Redo Buffers                   5480448 bytes
Automatic instance created

contents of Memory Script:
{
# set requested point in time
set until  scn 1756563;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log
sql 'alter system archive log current';
}
executing Memory Script

executing command: SET until clause

Starting restore at 25-FEB-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_ncsnf_TAG20140225T141016_9jstpk0l_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_ncsnf_TAG20140225T141016_9jstpk0l_.bkp tag=TAG20140225T141016
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata_aux/DB12CE/controlfile/o1_mf_9jsvpj6b_.ctl
Finished restore at 25-FEB-14

sql statement: alter database mount clone database

sql statement: alter system archive log current

contents of Memory Script:
{
# set requested point in time
set until  scn 1756563;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile  1 to new;
set newname for clone datafile  4 to new;
set newname for clone datafile  3 to new;
set newname for clone tempfile  1 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  1, 4, 3;
switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata_aux/DB12CE/datafile/o1_mf_temp_%u_.tmp in control file

Starting restore at 25-FEB-14
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata_aux/DB12CE/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata_aux/DB12CE/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata_aux/DB12CE/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_nnndf_TAG20140225T141016_9jstnrvh_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_nnndf_TAG20140225T141016_9jstnrvh_.bkp tag=TAG20140225T141016
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:46
Finished restore at 25-FEB-14

datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=840464948 file name=/u01/app/oracle/oradata_aux/DB12CE/datafile/o1_mf_system_9jsvpq1g_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=840464948 file name=/u01/app/oracle/oradata_aux/DB12CE/datafile/o1_mf_undotbs1_9jsvpq26_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=840464948 file name=/u01/app/oracle/oradata_aux/DB12CE/datafile/o1_mf_sysaux_9jsvpq20_.dbf

contents of Memory Script:
{
# set requested point in time
set until  scn 1756563;
# online the datafiles restored or switched
sql clone "alter database datafile  1 online";
sql clone "alter database datafile  4 online";
sql clone "alter database datafile  3 online";
# recover and open database read only
recover clone database tablespace  "SYSTEM", "UNDOTBS1", "SYSAUX";
sql clone 'alter database open read only';
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  1 online

sql statement: alter database datafile  4 online

sql statement: alter database datafile  3 online

Starting recover at 25-FEB-14
using channel ORA_AUX_DISK_1

starting media recovery

channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=18
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=19
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_annnn_TAG20140225T142415_9jsvh02b_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_annnn_TAG20140225T142415_9jsvh02b_.bkp tag=TAG20140225T142415
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/oradata_aux/1_18_840461430.dbf thread=1 sequence=18
archived log file name=/u01/app/oracle/oradata_aux/1_19_840461430.dbf thread=1 sequence=19
media recovery complete, elapsed time: 00:00:01
Finished recover at 25-FEB-14

sql statement: alter database open read only

contents of Memory Script:
{
   sql clone "create spfile from memory";
   shutdown clone immediate;
   startup clone nomount;
   sql clone "alter system set  control_files =
  ''/u01/app/oracle/oradata_aux/DB12CE/controlfile/o1_mf_9jsvpj6b_.ctl'' comment=
 ''RMAN set'' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
# mount database
sql clone 'alter database mount clone database';
}
executing Memory Script

sql statement: create spfile from memory

database closed
database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2296576 bytes
Variable Size                285213952 bytes
Database Buffers             775946240 bytes
Redo Buffers                   5480448 bytes

sql statement: alter system set  control_files =   ''/u01/app/oracle/oradata_aux/DB12CE/controlfile/o1_mf_9jsvpj6b_.ctl'' comment= ''RMAN set'' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2296576 bytes
Variable Size                285213952 bytes
Database Buffers             775946240 bytes
Redo Buffers                   5480448 bytes

sql statement: alter database mount clone database

contents of Memory Script:
{
# set requested point in time
set until  scn 1756563;
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile  6 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  6;
switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

Starting restore at 25-FEB-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata_aux/NOYA_PITR_DB12CE/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_nnndf_TAG20140225T141016_9jstnrvh_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_nnndf_TAG20140225T141016_9jstnrvh_.bkp tag=TAG20140225T141016
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 25-FEB-14

datafile 6 switched to datafile copy
input datafile copy RECID=8 STAMP=840464989 file name=/u01/app/oracle/oradata_aux/NOYA_PITR_DB12CE/datafile/o1_mf_users_9jsvsdwt_.dbf

contents of Memory Script:
{
# set requested point in time
set until  scn 1756563;
# online the datafiles restored or switched
sql clone "alter database datafile  6 online";
# recover and open resetlogs
recover clone database tablespace  "USERS", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  6 online

Starting recover at 25-FEB-14
using channel ORA_AUX_DISK_1

starting media recovery

channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=18
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=19
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_annnn_TAG20140225T142415_9jsvh02b_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DB12CE/backupset/2014_02_25/o1_mf_annnn_TAG20140225T142415_9jsvh02b_.bkp tag=TAG20140225T142415
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/oradata_aux/1_18_840461430.dbf thread=1 sequence=18
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oracle/oradata_aux/1_18_840461430.dbf RECID=16 STAMP=840464990
archived log file name=/u01/app/oracle/oradata_aux/1_19_840461430.dbf thread=1 sequence=19
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oracle/oradata_aux/1_19_840461430.dbf RECID=17 STAMP=840464990
media recovery complete, elapsed time: 00:00:00
Finished recover at 25-FEB-14

database opened

contents of Memory Script:
{
# create directory for datapump import
sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/u01/app/oracle/oradata_aux''";
# create directory for datapump export
sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/u01/app/oracle/oradata_aux''";
}
executing Memory Script

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01/app/oracle/oradata_aux''

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01/app/oracle/oradata_aux''

Performing export of tables...
   EXPDP> Starting "SYS"."TSPITR_EXP_noya_cawA":
   EXPDP> Estimate in progress using BLOCKS method...
   EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
   EXPDP> Total estimation using BLOCKS method: 192 KB
   EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
   EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
   EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
   EXPDP> . . exported "DEMO"."TEST"                               117.6 KB    5000 rows
   EXPDP> Master table "SYS"."TSPITR_EXP_noya_cawA" successfully loaded/unloaded
   EXPDP> ******************************************************************************
   EXPDP> Dump file set for SYS.TSPITR_EXP_noya_cawA is:
   EXPDP>   /u01/app/oracle/oradata_aux/tspitr_noya_52954.dmp
   EXPDP> Job "SYS"."TSPITR_EXP_noya_cawA" successfully completed at Tue Feb 25 14:30:56 2014 elapsed 0 00:00:32
Export completed

contents of Memory Script:
{
# shutdown clone before import
shutdown clone abort
}
executing Memory Script

Oracle instance shut down

Performing import of tables...
   IMPDP> Master table "SYS"."TSPITR_IMP_noya_Fkhc" successfully loaded/unloaded
   IMPDP> Starting "SYS"."TSPITR_IMP_noya_Fkhc":
   IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
   IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
   IMPDP> . . imported "DEMO"."TEST_BEFORE"                        117.6 KB    5000 rows
   IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
   IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
   IMPDP> Job "SYS"."TSPITR_IMP_noya_Fkhc" successfully completed at Tue Feb 25 14:31:22 2014 elapsed 0 00:00:08
Import completed

Removing automatic instance
Automatic instance removed
auxiliary instance file /u01/app/oracle/oradata_aux/DB12CE/datafile/o1_mf_temp_9jsvr95p_.tmp deleted
auxiliary instance file /u01/app/oracle/oradata_aux/NOYA_PITR_DB12CE/onlinelog/o1_mf_3_9jsvsk9h_.log deleted
auxiliary instance file /u01/app/oracle/oradata_aux/NOYA_PITR_DB12CE/onlinelog/o1_mf_2_9jsvsjn2_.log deleted
auxiliary instance file /u01/app/oracle/oradata_aux/NOYA_PITR_DB12CE/onlinelog/o1_mf_1_9jsvshw5_.log deleted
auxiliary instance file /u01/app/oracle/oradata_aux/NOYA_PITR_DB12CE/datafile/o1_mf_users_9jsvsdwt_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata_aux/DB12CE/datafile/o1_mf_sysaux_9jsvpq20_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata_aux/DB12CE/datafile/o1_mf_undotbs1_9jsvpq26_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata_aux/DB12CE/datafile/o1_mf_system_9jsvpq1g_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata_aux/DB12CE/controlfile/o1_mf_9jsvpj6b_.ctl deleted
auxiliary instance file tspitr_noya_52954.dmp deleted
Finished recover at 25-FEB-14

At this point my table is reimported to my database with the new name TEST_BEFORE:

SQL> conn demo/demo
Connected.
SQL> select table_name from user_tables;

TABLE_NAME
--------------------------------------------------------------------------------
TEST_BEFORE
TEST

Now lets check if the table restored contains the correct data:

SQL>  select text from demo.test_before where id in (1,50,610);

TEXT
--------------------------------------------------
this is a test
this is a test
this is a test

We can now replace our corrupted table with the one restored:

SQL> drop table demo.test;

Table dropped.

SQL> create table demo.test as select * from demo.test_before;

Table created.

You can choose to just export the table with datapump without reimporting it in the database. This option allow you to be ready to reimport if needed, here is the script you can use:

RECOVER TABLE 'DEMO'.'TEST'
UNTIL SCN 1853267
AUXILIARY DESTINATION '/u01/app/oracle/oradata_aux'  
DUMP FILE 'test_to_scn_1756563.dmp'
NOTABLEIMPORT;

Thats it.

24 thoughts on “RMAN table recovery (12c new feature)

  1. Great job…. I am starting the 12c migration approach and best features to test out prior to full upgrade in Development.

  2. Great!
    I tried to do something similar with tablespace pint in time recovery in Oracle 10 and this was hell!! ๐Ÿ™‚

    Regards.

  3. Great job, I need some information. How I am gonna get the changes recorded in which SCN ? for I example in live scenario.. user updated the table, how would I restore at that point ? from where I get the SCN of that time ?

    1. Hi Rakesh,

      As I mentioned at the begining of the post, the procedure to restore is identical to any RMAN restoration, you can choose to restore from a date, a scn or an archivelog sequence, if you don’t know the scn you can precise a date (set until time) or get the scn with that function :

      SQL> SELECT TIMESTAMP_TO_SCN(‘2014-03-12 08:25:00’) FROM dual;

      TIMESTAMP_TO_SCN(‘2014-03-1208:25:00’)
      ————————————–
      6170263709

      Hope this helps.

  4. Thanks for sharing Cyrille. Does the test case vary in case of multiple PDB’s in a CDB?

    1. There is a small variation of the RESTORE COMMAND, here is an exemple form oracle documentation :

      RECOVER TABLE HR.PDB_EMP OF PLUGGABLE DATABASE HR_PDB
      UNTIL TIME ‘SYSDATE-4’
      AUXILIARY DESTINATION ‘/tmp/backups’
      REMAP TABLE ‘HR’.’PDB_EMP’:’EMP_RECVR’;

  5. great work cyrille…it will be help full to all…keep posting….gaining begins with sharing…!! ๐Ÿ™‚

    1. In 11g it is TSPITR, not table level recovery, table recovery still uses TSPITR but now all operations are automated, from the auxiliary database creation to the table import back to your database.

  6. Great example, thanks for the explanation, especially for newbies like me.

    One question, do we have to gather stats afterwards? What about indexes?

    1. Hi Atiq,

      Thank you for reading my blog, to answer your questions, no you don’t have to gather statistics afterwards, statistics are imported back with the table.
      The same is true for indexes and constraints if you don’t remap the table like explained in the oracle documentation :

      “When you use the REMAP option, any named constraints and indexes are not imported. This is to avoid name conflicts with existing tables.”

      Cyrille

  7. This is nice, but what about single table restoration if table is indexed and index is located in separate tablespace/datafile? ORA-31693, ORA-00376, ORA-01110 ๐Ÿ™

  8. In this post I don’t want use import while restoring the table. i will use with NOTABLEIMPORT
    it will do table export only right. If use this option DUMP FILE ‘test.dmp’ the table size if its big then maybe we will face with error dumpfile exhausted error. To overcome this issue what we need to do. Please share if you have any information on this.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.