Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of Recover Table, the new feature of Oracle12 RMAN?

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what is the role of Recover Table, the new feature of Oracle12 RMAN". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the role of Recover Table, the new feature of Oracle12 RMAN?"

Before Oracle 12c, if a table was mistakenly deleted, the usual method was Flashback flashback or TSPITR. Enabling flashback consumes disk space, and if it is purge or passed through DDL, it will not be able to flashback. If the table space that needs to be restored is too large, TSPITR can take a very long time. 12c provides a new feature of Table Recovery that can be restored on a point-in-time basis for a single table (or a single table partition). This feature is used to restore tables directly from RMAN backups with the following features:

Does not affect other database objects in the database

Reduce time and disk space consumption, similar to earlier TSPIRT workflows

Restore tablespaces from another disk path

Export the desired table data

Import to the original database (optional)

Recover table can restore one or more tables or table partitions to a specified point in time without affecting the remaining database objects. You can use previously created RMAN backups to restore tables and table partitions to a specified point in time.

The table is restored to a secondary instance and can be selected:

Use the REMAP option to import the restored table into a new table or partition

Create an expdp dump file only in the restored table for import at other times

precondition

The target database must be in read-write mode.

The target database must be in ARCHIVELOG mode.

You must have RMAN backups of tables or table partitions because they exist at the point in time at which you want to restore these objects.

To restore a single table partition, the COMPATIBLE initialization parameter for the target database must be set to 11.1.0 or higher.

Make sure that AUXILIARY DESTINATION has enough space to restore system, sysaux, undo, and the tablespaces required to restore tables.

Please note that these files in the secondary target will be deleted automatically after the table is restored.

"you must use the AUXILIARY DESTINATION clause and one of the following clauses to specify the recovery point in time: UNTIL TIME, UNTIL SCN, or UNTIL SEQUENCE."

Use restriction

Tables and table partitions that belong to SYS mode cannot be restored.

Tables and table partitions in SYSTEM and SYSAUX tablespaces cannot be restored.

Tables and table partitions on the standby database cannot be restored.

Tables named NOT NULL constraints cannot be restored with the REMAP option.

When RMAN automatically processes the recovery table or table partition from the backup, it performs the following steps:

1. Determine which backups contain tables or table partitions that need to be restored, and then restore them at a specified time.

two。 Determine if there is enough space on the target host to create the auxiliary instance, which is used to handle the recovery of tables or partitions. If there is not enough space required, RMAN will report an error and exit the restore operation.

3. Creates an auxiliary database and restores the specified table or table partition to the auxiliary database at the specified time. The data file location of the secondary database can be specified in the command.

4. Create a data pump file (expdp dump file) that contains the recovery table or table partition. The name and location of the data pump can also be specified in the command.

5. (optional) Import the data pump file produced in the previous step into the target instance. Of course, you can also choose not to import, if you choose not to import, you must use impdp manual import.

6. (optional) rename restore tables or table partitions in the target database.

Working with scen

Table-level and table-partition-level recovery of RMAN works well in the following scenarios:

(1) A very small number of tables need to be restored to a specific point in time. In this case, TSPITR is not the most efficient solution because it restores all objects in the tablespace to a specified point in time.

(2) tables that have been logically corrupted or have been drop and purge need to be recovered.

(3) flashback is not available, for example, the required undo data is overwritten.

(4) data lost after the DDL operation modifies the table structure. Flashback table cannot scroll tables back and forth across DDL (for example, truncate).

Demonstrate the Recover table process here

Create a test table

SQL > create table t_recover_test as select * from dba_objects

Table created.

SQL > select count (*) from t_recover_test

COUNT (*)

-

72652

Backup

[oracle@localhost ~] $rman target /

Recovery Manager: Release 12.2.0.1.0-Production on Thu Jun 28 21:06:17 2018

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

Connected to target database: PCC (DBID=3164878903)

RMAN > backup database format'/ home/oracle/bak/db_%U'

Starting backup at 28-JUN-18

Using target database control file instead of recovery catalog

Allocated channel: ORA_DISK_1

Channel ORA_DISK_1: SID=61 device type=DISK

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=/home/oracle/oradata/pcc/system01.dbf

Input datafile file number=00003 name=/home/oracle/oradata/pcc/sysaux01.dbf

Input datafile file number=00004 name=/home/oracle/oradata/pcc/undotbs01.dbf

Input datafile file number=00005 name=/home/oracle/oradata/pcc/tbs_zyq01.dbf

Input datafile file number=00007 name=/home/oracle/oradata/pcc/users01.dbf

Channel ORA_DISK_1: starting piece 1 at 28-JUN-18

Channel ORA_DISK_1: finished piece 1 at 28-JUN-18

Piece handle=/home/oracle/bak/db_01t6k254_1_1 tag=TAG20180628T215236 comment=NONE

Channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15

Finished backup at 28-JUN-18

Starting Control File and SPFILE Autobackup at 28-JUN-18

Piece handle=/u01/app/oracle/product/12.2.0.1/dbs/c-3164878903-20180628-00 comment=NONE

Finished Control File and SPFILE Autobackup at 28-JUN-18

Restore tabl

[oracle@localhost ~] $rman target /

Recovery Manager: Release 12.2.0.1.0-Production on Fri Jun 29 00:52:29 2018

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

Connected to target database: PCC (DBID=3164878903)

RMAN > RECOVER TABLE zyq.t_recover_test

Until time "to_date ('2018-06-28 2315 515 5615 06mm hh34:mi:ss')"

AUXILIARY DESTINATION'/ data01'

REMAP TABLE zyq.t_recover_test:t_recover_test_map

Starting recover at 29-JUN-18

Using target database control file instead of recovery catalog

Allocated channel: ORA_DISK_1

Channel ORA_DISK_1: SID=66 device type=DISK

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='hCed'

Initialization parameters used for automatic instance:

Db_name=PCC

Db_unique_name=hCed_pitr_PCC

Compatible=12.2.0

Db_block_size=8192

Db_files=200

Diagnostic_dest=/u01/app/oracle

_ system_trig_enabled=FALSE

Sga_target=732M

Processes=200

Db_create_file_dest=/data01

Log_archive_dest_1='location=/data01'

# No auxiliary parameter file used

Starting up automatic instance PCC

Oracle instance started

Total System Global Area 767557632 bytes

Fixed Size 8625416 bytes

Variable Size 213910264 bytes

Database Buffers 541065216 bytes

Redo Buffers 3956736 bytes

Automatic instance created

Contents of Memory Script:

{

# set requested point in time

Set until time "to_date ('2018-06-28 2315 515 5615 06mm hh34:mi:ss')"

# 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 29-JUN-18

Allocated channel: ORA_AUX_DISK_1

Channel ORA_AUX_DISK_1: SID=35 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/product/12.2.0.1/dbs/c-3164878903-20180628-01

Channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/product/12.2.0.1/dbs/c-3164878903-20180628-01 tag=TAG20180628T234914

Channel ORA_AUX_DISK_1: restored backup piece 1

Channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02

Output file name=/data01/PCC/controlfile/o1_mf_fmcsc00p_.ctl

Finished restore at 29-JUN-18

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 time "to_date ('2018-06-28 2315 515 5615 06mm hh34:mi:ss')"

# 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 / data01/PCC/datafile/o1_mf_temp_%u_.tmp in control file

Starting restore at 29-JUN-18

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 / data01/PCC/datafile/o1_mf_system_%u_.dbf

Channel ORA_AUX_DISK_1: restoring datafile 00004 to / data01/PCC/datafile/o1_mf_undotbs1_%u_.dbf

Channel ORA_AUX_DISK_1: restoring datafile 00003 to / data01/PCC/datafile/o1_mf_sysaux_%u_.dbf

Channel ORA_AUX_DISK_1: reading from backup piece / home/oracle/bak/db_01t6k254_1_1

Channel ORA_AUX_DISK_1: piece handle=/home/oracle/bak/db_01t6k254_1_1 tag=TAG20180628T215236

Channel ORA_AUX_DISK_1: restored backup piece 1

Channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15

Finished restore at 29-JUN-18

Datafile 1 switched to datafile copy

Input datafile copy RECID=4 STAMP=980038406 file name=/data01/PCC/datafile/o1_mf_system_fmcsc755_.dbf

Datafile 4 switched to datafile copy

Input datafile copy RECID=5 STAMP=980038406 file name=/data01/PCC/datafile/o1_mf_undotbs1_fmcsc75h_.dbf

Datafile 3 switched to datafile copy

Input datafile copy RECID=6 STAMP=980038406 file name=/data01/PCC/datafile/o1_mf_sysaux_fmcsc75c_.dbf

Contents of Memory Script:

{

# set requested point in time

Set until time "to_date ('2018-06-28 2315 515 5615 06mm hh34:mi:ss')"

# 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 29-JUN-18

Using channel ORA_AUX_DISK_1

Starting media recovery

Archived log for thread 1 with sequence 3 is already on disk as file / u01/app/oracle/product/12.2.0.1/dbs/arch2_3_979872889.dbf

Archived log for thread 1 with sequence 4 is already on disk as file / u01/app/oracle/product/12.2.0.1/dbs/arch2_4_979872889.dbf

Archived log file name=/u01/app/oracle/product/12.2.0.1/dbs/arch2_3_979872889.dbf thread=1 sequence=3

Archived log file name=/u01/app/oracle/product/12.2.0.1/dbs/arch2_4_979872889.dbf thread=1 sequence=4

Media recovery complete, elapsed time: 00:00:11

Finished recover at 29-JUN-18

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 =

'' / data01/PCC/controlfile/o1_mf_fmcsc00p_.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 767557632 bytes

Fixed Size 8625416 bytes

Variable Size 213910264 bytes

Database Buffers 541065216 bytes

Redo Buffers 3956736 bytes

Sql statement: alter system set control_files ='/ data01/PCC/controlfile/o1_mf_fmcsc00p_.ctl'' comment=''RMAN set'' scope=spfile

Oracle instance shut down

Connected to auxiliary database (not started)

Oracle instance started

Total System Global Area 767557632 bytes

Fixed Size 8625416 bytes

Variable Size 213910264 bytes

Database Buffers 541065216 bytes

Redo Buffers 3956736 bytes

Sql statement: alter database mount clone database

Contents of Memory Script:

{

# set requested point in time

Set until time "to_date ('2018-06-28 2315 515 5615 06mm hh34:mi:ss')"

# set destinations for recovery set and auxiliary set datafiles

Set newname for datafile 5 to new

# restore the tablespaces in the recovery set and the auxiliary set

Restore clone datafile 5

Switch clone datafile all

}

Executing Memory Script

Executing command: SET until clause

Executing command: SET NEWNAME

Starting restore at 29-JUN-18

Allocated channel: ORA_AUX_DISK_1

Channel ORA_AUX_DISK_1: SID=34 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 00005 to / data01/HCED_PITR_PCC/datafile/o1_mf_tbs_zyq_%u_.dbf

Channel ORA_AUX_DISK_1: reading from backup piece / home/oracle/bak/db_01t6k254_1_1

Channel ORA_AUX_DISK_1: piece handle=/home/oracle/bak/db_01t6k254_1_1 tag=TAG20180628T215236

Channel ORA_AUX_DISK_1: restored backup piece 1

Channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03

Finished restore at 29-JUN-18

Datafile 5 switched to datafile copy

Input datafile copy RECID=8 STAMP=980038478 file name=/data01/HCED_PITR_PCC/datafile/o1_mf_tbs_zyq_fmcsfttn_.dbf

Contents of Memory Script:

{

# set requested point in time

Set until time "to_date ('2018-06-28 2315 515 5615 06mm hh34:mi:ss')"

# online the datafiles restored or switched

Sql clone "alter database datafile 5 online"

# recover and open resetlogs

Recover clone database tablespace "TBS_ZYQ", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog

Alter clone database open resetlogs

}

Executing Memory Script

Executing command: SET until clause

Sql statement: alter database datafile 5 online

Starting recover at 29-JUN-18

Using channel ORA_AUX_DISK_1

Starting media recovery

Archived log for thread 1 with sequence 3 is already on disk as file / u01/app/oracle/product/12.2.0.1/dbs/arch2_3_979872889.dbf

Archived log for thread 1 with sequence 4 is already on disk as file / u01/app/oracle/product/12.2.0.1/dbs/arch2_4_979872889.dbf

Archived log file name=/u01/app/oracle/product/12.2.0.1/dbs/arch2_3_979872889.dbf thread=1 sequence=3

Archived log file name=/u01/app/oracle/product/12.2.0.1/dbs/arch2_4_979872889.dbf thread=1 sequence=4

Media recovery complete, elapsed time: 00:00:01

Finished recover at 29-JUN-18

Database opened

Contents of Memory Script:

{

# create directory for datapump import

Sql "create or replace directory TSPITR_DIROBJ_DPDIR as''

/ data01'' "

# create directory for datapump export

Sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as''

/ data01'' "

}

Executing Memory Script

Sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as'/ data01''

Sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as'/ data01''

Performing export of tables...

EXPDP > Starting "SYS". "TSPITR_EXP_hCed_Dhxe":

EXPDP > Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

EXPDP > Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

EXPDP > Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER

EXPDP > Processing object type TABLE_EXPORT/TABLE/TABLE

EXPDP >. . Exported "ZYQ". "T_RECOVER_TEST" 9.324 MB 72652 rows

EXPDP > Master table "SYS". "TSPITR_EXP_hCed_Dhxe" successfully loaded/unloaded

EXPDP > *

EXPDP > Dump file set for SYS.TSPITR_EXP_hCed_Dhxe is:

EXPDP > / data01/tspitr_hCed_71393.dmp

EXPDP > Job "SYS". "TSPITR_EXP_hCed_Dhxe" successfully completed at Fri Jun 29 00:55:41 2018 elapsed 0 00:00:35

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_hCed_Arhm" successfully loaded/unloaded

IMPDP > Starting "SYS". "TSPITR_IMP_hCed_Arhm":

IMPDP > Processing object type TABLE_EXPORT/TABLE/TABLE

IMPDP > Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

IMPDP >. . Imported "ZYQ". "T_RECOVER_TEST_MAP" 9.324 MB 72652 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_hCed_Arhm" successfully completed at Fri Jun 29 00:56:43 2018 elapsed 0 00:00:45

Import completed

Removing automatic instance

Automatic instance removed

Auxiliary instance file/ data01/PCC/datafile/o1_mf_temp_fmcsd5ny_.tmp deleted

Auxiliary instance file / data01/HCED_PITR_PCC/onlinelog/o1_mf_3_fmcsg3y6_.log deleted

Auxiliary instance file / data01/HCED_PITR_PCC/onlinelog/o1_mf_2_fmcsg07o_.log deleted

Auxiliary instance file / data01/HCED_PITR_PCC/onlinelog/o1_mf_1_fmcsfzr1_.log deleted

Auxiliary instance file/ data01/HCED_PITR_PCC/datafile/o1_mf_tbs_zyq_fmcsfttn_.dbf deleted

Auxiliary instance file/ data01/PCC/datafile/o1_mf_sysaux_fmcsc75c_.dbf deleted

Auxiliary instance file/ data01/PCC/datafile/o1_mf_undotbs1_fmcsc75h_.dbf deleted

Auxiliary instance file/ data01/PCC/datafile/o1_mf_system_fmcsc755_.dbf deleted

Auxiliary instance file/ data01/PCC/controlfile/o1_mf_fmcsc00p_.ctl deleted

Auxiliary instance file tspitr_hCed_71393.dmp deleted

Finished recover at 29-JUN-18

RMAN >

Verification

SQL > select count (*) from T_RECOVER_TEST_MAP

COUNT (*)

-

72652

Thank you for reading, the above is the content of "what is the role of Recover Table, the new feature of Oracle12 RMAN?" after the study of this article, I believe you have a deeper understanding of the role of Recover Table, the new feature of Oracle12 RMAN, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report