In the past, when a table was deleted or had to come back after a certain period of time for any reason, it did a lot of unnecessary work. With Oracle Database 12C, we had the chance to bring the table back to our lives with Table Point In Time Recovery, in other words, with a single action from the backup.
In today’s article, we will recognize this feature that can be used in Oracle Database 12C and higher versions. The process logically opens a new instance for you and registers a database with your table on this instance. After registration, the table is taken out and imported into your existing database. You can do this by going to a certain date or according to the SCN or Sequence number, but there are some situations that we need to pay attention to. When you use the RECOVER command to recover tables or table partitions contained in an RMAN backup, the following limitations exist.
- The database must be on the archivemod.
- Tables and table partitions belonging to the SYS scheme cannot be recovered.
- Tables and table partitions cannot be recovered from SYSTEM and SYSAUX table fields.
- Tables and table partitions in standby databases cannot be recovered.
- Tables with NOT NULL constraints cannot be recovered with the REMAP option.
Recovering tables or table partitions in RMAN backup with example
We will explain with an example of the test database.
oracle@node1 ~]$ rman target / RMAN> backup database plus archivelog; Starting backup at 04-NOV-20 current log archived allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=406 instance=OMERDB1 device type=DISK 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=19 RECID=1 STAMP=1051267492 channel ORA_DISK_1: starting piece 1 at 04-NOV-20 channel ORA_DISK_1: finished piece 1 at 04-NOV-20 piece handle=+FRA/OMERDB/BACKUPSET/2020_11_14/annnf0_tag20200916t104453_0.261.1051267493 tag=TAG20200916T104453 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 01:00:01 Finished backup at 04-NOV-20 . . . . . . Starting Control File and SPFILE Autobackup at 04-NOV-20 piece handle=+FRA/OMERDB/AUTOBACKUP/2020_11_04/s_1051267503.265.1051267505 comment=NONE Finished Control File and SPFILE Autobackup at 04-NOV-20 RMAN> Recovery Manager complete.
Recovery process by date
Now we will prepare a suitable environment for recovery. For example, we will recover according to the date. We will check our database clock and delete a sample table. We want to return our database clock ”04/11/2020 22:59:12” to this hour. There is a directory named ”/u01/tempdata/bgrdb” on the file system. The database will temporarily use this location.
[oracle@node1 ~]$ !sql sqlplus / as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Wed Nov 04 22:45:58 2020 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> alter session set nls_date_format = 'dd/mm/yyyy hh24:mi:ss'; Session altered. SQL> select sysdate from dual; SYSDATE ------------------- 04/11/2020 22:59:12
Delete table
First of all, we delete our table according to the scenario.
SQL> drop table omer.personel; Table dropped. SQL> commit; Commit complete.
Starting recovery
We start recovery with history.
RMAN> recover table "OMER"."PERSONEL" until time "to_date('04/11/2020 22:59:12','dd/mm/yyyy hh24:mi:ss')" AUXILIARY DESTINATION '/u01/tempdata/bgrdb';
Using SCN
If you want to do it with SCN, you can use the code below.
RMAN> recover table "OMER"."PERSONEL" UNTIL SCN 238107 AUXILIARY DESTINATION '/u01/tempdata/bgrdb';
Recovery startup
We’re starting the recovery.
Starting recover at 04-NOV-20
current log archived
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='Aglq'
initialization parameters used for automatic instance:
db_name=OMERDB
db_unique_name=Aglq_pitr_OMERDB
compatible=19.0.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle/database/19.3.0
_system_trig_enabled=FALSE
sga_target=3536M
processes=200
db_create_file_dest=/u01/tempdata/bgrdb
log_archive_dest_1='location=/u01/tempdata/bgrdb'
#No auxiliary parameter file used
starting up automatic instance OMERDB
Oracle instance started
Total System Global Area 3707763120 bytes
Fixed Size 8903088 bytes
Variable Size 721420288 bytes
Database Buffers 2969567232 bytes
Redo Buffers 7872512 bytes
Automatic instance created
contents of Memory Script:
{
# set requested point in time
set until time "to_date('04/11/2020 22:59:12','dd/mm/yyyy hh24:mi:ss')";
# restore the controlfile
restore clone controlfile;
.
.
.
.
.
.
IMPDP> . . imported "OMER"."PERSONEL":"SYS_P317" 9.890 KB 5 rows
IMPDP> . . imported "OMER"."PERSONEL":"SYS_P318" 9.968 KB 6 rows
IMPDP> . . imported "OMER"."PERSONEL":"SYS_P319" 9.906 KB 5 rows
IMPDP> . . imported "OMER"."PERSONEL":"SYS_P320" 10.03 KB 7 rows
IMPDP> Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
IMPDP> Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
IMPDP> Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
IMPDP> Job "SYS"."TSPITR_IMP_Aglq_spDm" successfully completed at Wed Nov 04 23:04:59 2020 elapsed 0 00:00:49
Import completed
Removing automatic instance
Automatic instance removed
auxiliary instance file /u01/tempdata/bgrdb/OMERDB/datafile/o1_mf_temp_hp3qqmch_.tmp deleted
auxiliary instance file /u01/tempdata/bgrdb/FGVT_PITR_OMERDB/onlinelog/o1_mf_3_hp3qtobf_.log deleted
auxiliary instance file /u01/tempdata/bgrdb/FGVT_PITR_OMERDB/onlinelog/o1_mf_2_hp3qto97_.log deleted
auxiliary instance file /u01/tempdata/bgrdb/FGVT_PITR_OMERDB/onlinelog/o1_mf_1_hp3qto86_.log deleted
auxiliary instance file /u01/tempdata/bgrdb/FGVT_PITR_OMERDB/datafile/o1_mf_users_hp3qtgm4_.dbf deleted
auxiliary instance file /u01/tempdata/bgrdb/OMERDB/datafile/o1_mf_sysaux_hp3qq94b_.dbf deleted
auxiliary instance file /u01/tempdata/bgrdb/OMERDB/datafile/o1_mf_undotbs1_hp3qq948_.dbf deleted
auxiliary instance file /u01/tempdata/bgrdb/OMERDB/datafile/o1_mf_system_hp3qq945_.dbf deleted
auxiliary instance file /u01/tempdata/bgrdb/OMERDB/controlfile/o1_mf_hp3qq29q_.ctl deleted
auxiliary instance file tspitr_fgvt_61116.dmp deleted
Finished recover at 04-NOV-20
Added instance
Transactions are completed. As you can see, Oracle is doing what we used to do manually in the past. As an example, you can see the added instance while performing the process on the screen below.

Export for table
Our table has been recovered with the two examples we have given successfully. If you want, you can do not recover but export for this table.
RMAN> recover table "OMER"."PERSONEL" UNTIL SCN 238107 AUXILIARY DESTINATION '/u01/tempdata/bgrdb' DATAPUMP DESTINATION '/tempdata/export' DUMP FILE 'personnel_reserve.dmp' NOTABLEIMPORT;
Recovery under a different name
Or you can recover the table with a different name.
RMAN> recover table "OMER"."PERSONEL" until time "to_date('04/11/2020 22:59:12','dd/mm/yyyy hh24:mi:ss')" AUXILIARY DESTINATION '/u01/tempdata/bgrdb' REMAP TABLE 'OMER'.'PERSONEL':'PERSONEL_BCK';
Different tablespace
Finally, as you can recover the table with a different name, you can get it on different tablespaces.
RMAN> recover table "OMER"."PERSONEL" until time "to_date('04/11/2020 22:59:12','dd/mm/yyyy hh24:mi:ss')" AUXILIARY DESTINATION '/u01/tempdata/bgrdb' REMAP TABLE 'OMER'.'PERSONEL':'EXPERT'PERSONEL_BCK' REMAP TABLESPACE 'TS_OMER':'TS_OTHER';
