{"id":15,"date":"2023-07-18T11:01:00","date_gmt":"2023-07-18T11:01:00","guid":{"rendered":"https:\/\/oracleconraul.wordpress.com\/?p=10"},"modified":"2023-07-20T15:54:26","modified_gmt":"2023-07-20T15:54:26","slug":"restore-table-with-rman","status":"publish","type":"post","link":"https:\/\/oracleconraul.com\/index.php\/2023\/07\/18\/restore-table-with-rman\/","title":{"rendered":"Restaurar una tabla con RMAN"},"content":{"rendered":"\n<p>En la versi\u00f3n 12c, se introdujeron muchas y muy \u00fatiles nuevas funcionalidades. Entre ellas, la posibilidad de recuperar una tabla con RMAN. Esta caracter\u00edstica se aplica tanto a arquitecturas Multitenant como no Multitenant, permiti\u00e9ndote recuperar una tabla de una PDB si ese fuera el caso.<br><br>En el siguiente enlace podemos encontrar la nota oficial:<\/p>\n\n\n\n<p class=\"has-ast-global-color-0-color has-text-color\"><strong>RMAN Recover Table Feature in Oracle Database 12c and Higher (Doc ID 1521524.1)<\/strong><\/p>\n\n\n\n<p>En este ejemplo de prueba vamos a recuperar una tabla creada en el esquema raul de la PDB \u201cORCLPDB1\u201d dentro de la base de datos, cuya CDB es \u201cORCLCDB\u201d<\/p>\n\n\n\n<p class=\"has-ast-global-color-8-color has-ast-global-color-4-background-color has-text-color has-background has-small-font-size\">SQL&gt; show con_name<br>CON_NAME<br>\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<br>ORCLPDB1<\/p>\n\n\n\n<p class=\"has-ast-global-color-8-color has-ast-global-color-4-background-color has-text-color has-background has-small-font-size\">SQL&gt; show con_id<br>CON_ID<br>\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<br>3<\/p>\n\n\n\n<p>Para ello, vamos a crear una tabla simple, e insertamos 5 valores:<\/p>\n\n\n\n<p class=\"has-ast-global-color-8-color has-ast-global-color-4-background-color has-text-color has-background has-small-font-size\">SQL&gt; create table uno (dni number);<br>Table created.<br>SQL&gt;insert into uno values (1);<br>SQL&gt;insert into uno values (2);<br>SQL&gt;insert into uno values (3);<br>SQL&gt;insert into uno values (4);<br>SQL&gt;insert into uno values (5);<br>SQL&gt; commit;<\/p>\n\n\n\n<p class=\"has-ast-global-color-8-color has-ast-global-color-4-background-color has-text-color has-background has-small-font-size\"><br>SQL&gt;&nbsp; select * from uno<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DNI<br>\u2014\u2014\u2014\u2014\u2013<br>1<br>2<br>3<br>4<br>5<\/p>\n\n\n\n<p>Realizamos el backup de la base de datos con el que recuperaremos la tabla posteriormente.<\/p>\n\n\n\n<p>Conectados a la CDB, realizaremos un backup completo de la base de datos y los archives:<\/p>\n\n\n\n<p class=\"has-ast-global-color-8-color has-ast-global-color-4-background-color has-text-color has-background has-small-font-size\">[oracle@oracle21c ~]$ rman<br>Recovery Manager: Release 19.0.0.0.0 \u2013 Production on Thu Nov 3 17:43:08 2022<br>Version 19.3.0.0.0<br>Copyright (c) 1982, 2019, Oracle and\/or its affiliates.&nbsp; All rights reserved.<br>RMAN&gt; connect target \/<br>connected to target database: ORCLCDB (DBID=2778750799)<br>RMAN&gt;<strong>&nbsp;backup database plus archivelog;<\/strong><br>Starting backup at 2022-11-03:17:43:30<br>current log archived<br>using target database control file instead of recovery catalog<br>allocated channel: ORA_DISK_1<br>channel ORA_DISK_1: SID=293 device type=DISK<br>channel ORA_DISK_1: starting archived log backup set<br>channel ORA_DISK_1: specifying archived log(s) in backup set<br>input archived log thread=1 sequence=19 RECID=1 STAMP=1104223655t<br>.<br>.<br>input archived log thread=1 sequence=26 RECID=8 STAMP=1119807810<br>channel ORA_DISK_1: starting piece 1 at 2022-11-03:17:43:31<br>channel ORA_DISK_1: finished piece 1 at 2022-11-03:17:43:34<br>.<br>.<br>channel ORA_DISK_1: starting full datafile backup set<br>channel ORA_DISK_1: specifying datafile(s) in backup set<br>input datafile file number=00010 name=\/u01\/app\/oracle\/oradata\/ORCLCDB\/orclpdb1\/sysaux01.dbf<br>input datafile file number=00012 name=\/u01\/app\/oracle\/oradata\/ORCLCDB\/orclpdb1\/users01.dbf<br>.<br>.<br>channel ORA_DISK_1: starting piece 1 at 2022-11-03:17:44:11<br>channel ORA_DISK_1: finished piece 1 at 2022-11-03:17:44:12<br>piece handle=\/u01\/app\/oracle\/fast_recovery_area\/ORCLCDB\/backupset\/2022_11_03\/o1_mf_annnn_TAG20221103T174411_kp7zhcyq_.bkp tag=TAG20221103T174411 comment=NONE<br>channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01<br>Finished backup at 2022-11-03:17:44:12<br>Starting Control File and SPFILE Autobackup at 2022-11-03:17:44:13<br>piece handle=\/u01\/app\/oracle\/fast_recovery_area\/ORCLCDB\/autobackup\/2022_11_03\/o1_mf_s_1119807853_kp7zhfc2_.bkp comment=NONE<br>.<br>Finished Control File and SPFILE Autobackup at 2022-11-03:17:44:14<br>RMAN&gt;<\/p>\n\n\n\n<p>Para verificar que hemos realizado correctamente la copia de nuestra base de datos (PDB) y del tablespace donde tenemos albergada nuestra tabla, en nuestro caso&nbsp;<strong>ORCLPDB1:USERS<\/strong>, podemos ejecutar el comando \u00abreport schema\u00bb.<\/p>\n\n\n\n<p class=\"has-ast-global-color-8-color has-ast-global-color-4-background-color has-text-color has-background has-small-font-size\">RMAN&gt; connect target \/<br>connected to target database: ORCLCDB (DBID=2778750799)<br>using target database control file instead of recovery catalog<br>RMAN&gt;<br>RMAN&gt; report schema;<br><br>Report of database schema for database with db_unique_name ORCLCDB<br>List of Permanent Datafiles<br>===========================<br>File Size(MB) Tablespace&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RB segs Datafile Name<br>\u2014- \u2014\u2014\u2013 \u2014\u2014\u2014\u2014\u2014\u2014\u2013 \u2014\u2014- \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<br>1&nbsp;&nbsp;&nbsp; 920&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SYSTEM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; YES&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/system01.dbf<br>3&nbsp;&nbsp;&nbsp; 850&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SYSAUX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/sysaux01.dbf<br>4&nbsp;&nbsp;&nbsp; 330&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNDOTBS1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; YES&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/undotbs01.dbf<br>5&nbsp;&nbsp;&nbsp; 270&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PDB$SEED:SYSTEM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/pdbseed\/system01.dbf<br>6&nbsp;&nbsp;&nbsp; 330&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PDB$SEED:SYSAUX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/pdbseed\/sysaux01.dbf<br>7&nbsp;&nbsp;&nbsp; 5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; USERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/users01.dbf<br>8&nbsp;&nbsp;&nbsp; 100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PDB$SEED:UNDOTBS1&nbsp;&nbsp;&nbsp; NO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/pdbseed\/undotbs01.dbf<br>9&nbsp;&nbsp;&nbsp; 280&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORCLPDB1:SYSTEM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; YES&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/orclpdb1\/system01.dbf<br>10&nbsp;&nbsp; 370&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORCLPDB1:SYSAUX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/orclpdb1\/sysaux01.dbf<br>11&nbsp;&nbsp; 100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORCLPDB1:UNDOTBS1&nbsp;&nbsp;&nbsp; YES&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/orclpdb1\/undotbs01.dbf<br><strong>12&nbsp;&nbsp; 342&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORCLPDB1:USERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/orclpdb1\/users01.dbf<\/strong><br>13&nbsp;&nbsp; 280&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORCLPDB2:SYSTEM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; YES&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/orclpdb2\/system01.dbf<br>14&nbsp;&nbsp; 370&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORCLPDB2:SYSAUX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/orclpdb2\/sysaux01.dbf<br>15&nbsp;&nbsp; 100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORCLPDB2:UNDOTBS1&nbsp;&nbsp;&nbsp; YES&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/orclpdb2\/undotbs01.dbf<br>16&nbsp;&nbsp; 342&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORCLPDB2:USERS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/orclpdb2\/users01.dbf<br>List of Temporary Files<br>=======================<br>File Size(MB) Tablespace&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Maxsize(MB) Tempfile Name<br>\u2014- \u2014\u2014\u2013 \u2014\u2014\u2014\u2014\u2014\u2014\u2013 \u2014\u2014\u2014\u2013 \u2014\u2014\u2014\u2014\u2014\u2014\u2013<br>1&nbsp;&nbsp;&nbsp; 131&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TEMP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 32767&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/temp01.dbf<br>2&nbsp;&nbsp;&nbsp; 36&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PDB$SEED:TEMP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 32767&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/pdbseed\/temp012019-05-08_01-48-43-006-AM.dbf<br>3&nbsp;&nbsp;&nbsp; 36&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORCLPDB1:TEMP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 32767&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/orclpdb1\/temp01.dbf<br>4&nbsp;&nbsp;&nbsp; 36&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORCLPDB2:TEMP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 32767&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDB\/orclpdb2\/temp01.dbf<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Recuperaci\u00f3n de la tabla.<\/strong><\/p>\n\n\n\n<p>Es bastante importante definir un formato de fecha, especialmente en RMAN a la hora de recuperar la tabla, ya que este ser\u00e1 el formato que usar\u00e1 la herramienta para recuperar la tabla.<br><br>En este ejemplo vamos a realizar el borrado de la tabla para luego recuperarla.<\/p>\n\n\n\n<p class=\"has-ast-global-color-8-color has-ast-global-color-4-background-color has-text-color has-background has-small-font-size\">SQL&gt; alter session set nls_date_format = \u2018dd\/mm\/yyyy hh24:mi:ss\u2019;<br>Session altered.<br><br>SQL&gt; select sysdate from dual;<br>SYSDATE<br>\u2014\u2014\u2014\u2014-<br>03\/11\/2022 22:14:14<br><br>SQL&gt; drop table uno;<\/p>\n\n\n\n<p>Lanzamos el restore. Ejecutamos el script recover_table.bck, donde se indica que queremos restaurar la tabla UNO justo a la fecha y hora antes del borrado de la tabla. Como se puede observar, lo que hace RMAN una vez restaurado el backup de RMAN, es exportar e importar a trav\u00e9s de un import los datos de la tabla borrada.<\/p>\n\n\n\n<p class=\"has-ast-global-color-8-color has-ast-global-color-4-background-color has-text-color has-background has-small-font-size\">RMAN&gt; connect target \/<br>connected to target database: ORCLCDB (DBID=2778750799)<br>RMAN&gt;&nbsp;<strong>@recover_table.bck<\/strong><br>RMAN&gt;&nbsp;<strong>run{<\/strong><br>2&gt;&nbsp;<strong>recover table \u00abRAUL\u00bb.\u00bbUNO\u00bb OF PLUGGABLE DATABASE ORCLPDB1<\/strong><br>3&gt;&nbsp;<strong>until time \u00abto_date(\u201903\/11\/2022 22:14:14\u2032,\u2019dd\/mm\/yyyy hh24:mi:ss\u2019)\u00bb<\/strong><br>4&gt;&nbsp;<strong>AUXILIARY DESTINATION \u2018\/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\u2019;<\/strong><br>5&gt;<strong>&nbsp;}<\/strong><br>Starting recover at 2022-11-03:23:10:23<br>using target database control file instead of recovery catalog<br>current log archived<br>allocated channel: ORA_DISK_1<br>channel ORA_DISK_1: SID=303 device type=DISK<br>RMAN-05026: warning: presuming following set of tablespaces applies to specified point-in-time<br>List of tablespaces expected to have UNDO segments<br>Tablespace SYSTEM<br>Tablespace ORCLPDB1:SYSTEM<br>Tablespace UNDOTBS1<br>db_name=ORCLCDB<br>db_unique_name=wdum_pitr_ORCLPDB1_ORCLCDB<br>compatible=19.0.0<br>db_create_file_dest=\/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE<br>log_archive_dest_1=\u2019location=\/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\u2019<br>enable_pluggable_database=true<br>_clone_one_pdb_recovery=true<br>#No auxiliary parameter file used<br>starting up automatic instance ORCLCDB<br>Oracle instance started<br>contents of Memory Script:<br>{<br># set requested point in time<br>set until&nbsp; time \u00abto_date(\u201903\/11\/2022 22:14:14\u2032,\u2019dd\/mm\/yyyy hh24:mi:ss\u2019)\u00bb;<br># restore the controlfile<br>channel ORA_AUX_DISK_1: reading from backup piece \/u01\/app\/oracle\/fast_recovery_area\/ORCLCDB\/autobackup\/2022_11_03\/o1_mf_s_1119807853_kp7zhfc2_.bkp<br>channel ORA_AUX_DISK_1: reading from backup piece \/u01\/app\/oracle\/fast_recovery_area\/ORCLCDB\/autobackup\/2022_11_03\/o1_mf_s_1119807853_kp7zhfc2_.bkp<br>.<br>.<br>channel ORA_AUX_DISK_1: piece handle=\/u01\/app\/oracle\/fast_recovery_area\/ORCLCDB\/autobackup\/2022_11_03\/o1_mf_s_1119807853_kp7zhfc2_.bkp tag=TAG20221103T174413<br>.<br>.<br>{<br># set requested point in time<br>set until&nbsp; time \u00abto_date(\u201903\/11\/2022 22:14:14\u2032,\u2019dd\/mm\/yyyy hh24:mi:ss\u2019)\u00bb;<br># set destinations for recovery set and auxiliary set datafiles<br>.<br>.<br>set newname for clone tempfile&nbsp; 3 to new;<br># switch all tempfiles<br>switch clone tempfile all;<br># restore the tablespaces in the recovery set and the auxiliary set<br>restore clone datafile&nbsp; 1, 9, 4, 11, 3, 10;<br>switch clone datafile all;<br>}<br>executing Memory Script<br>.<br>.<br>renamed tempfile 1 to \/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\/ORCLCDB\/datafile\/o1_mf_temp_%u_.tmp in control file<br>renamed tempfile 3 to \/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\/ORCLCDB\/8857B36632797E5CE0536210ED0ADAC7\/datafile\/o1_mf_temp_%u_.tmp in control file<br>Starting restore at 2022-11-03:23:10:48<br><br>using channel ORA_AUX_DISK_1<br>channel ORA_AUX_DISK_1: starting datafile backup set restore<br>channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set<br>channel ORA_AUX_DISK_1: restoring datafile 00001 to \/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\/ORCLCDB\/datafile\/o1_mf_system_%u_.dbf<br>channel ORA_AUX_DISK_1: restoring datafile 00004 to \/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\/ORCLCDB\/datafile\/o1_mf_undotbs1_%u_.dbf<br>.<br>.<br>channel ORA_AUX_DISK_1: restoring datafile 00010 to \/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\/ORCLCDB\/8857B36632797E5CE0536210ED0ADAC7\/datafile\/o1_mf_sysaux_%u_.dbf<br>channel ORA_AUX_DISK_1: reading from backup piece<br>\/u01\/app\/oracle\/fast_recovery_area\/ORCLCDB\/8857B36632797E5CE0536210ED0ADAC7\/backupset\/2022_11_03\/o1_mf_nnndf_TAG20221103T174334_kp7zgp9h_.bkp<br>channel ORA_AUX_DISK_1: piece<br>handle=\/u01\/app\/oracle\/fast_recovery_area\/ORCLCDB\/8857B36632797E5CE0536210ED0ADAC7\/backupset\/2022_11_03\/o1_mf_nnndf_TAG20221103T174334_kp7zgp9h_.bkp<br>tag=TAG20221103T174334<br>channel ORA_AUX_DISK_1: restored backup piece 1<br>.<br>.<br>contents of Memory Script:<br>{<br># set requested point in time<br>.<br>.<br># recover and open database read only<br>recover clone database tablespace&nbsp; \u00abSYSTEM\u00bb, \u00abORCLPDB1\u2033:\u00bbSYSTEM\u00bb, \u00abUNDOTBS1\u00bb, \u00abORCLPDB1\u2033:\u00bbUNDOTBS1\u00bb, \u00abSYSAUX\u00bb, \u00abORCLPDB1\u2033:\u00bbSYSAUX\u00bb;<br>sql clone \u2018alter database open read only\u2019;<br>}<br>executing Memory Script<br>executing command: SET until clause<br>.<br>.<br>using channel ORA_AUX_DISK_1<br>starting media recovery<br>.<br>.<br>media recovery complete, elapsed time: 00:00:04<br>Finished recover at 2022-11-03:23:11:17<br>sql statement: alter database open read only<br>contents of Memory Script:<br>{<br>sql clone \u2018alter pluggable database&nbsp; ORCLPDB1 open read only\u2019;<br>}<br>executing Memory Script<br>sql statement: alter pluggable database&nbsp; ORCLPDB1 open read only<br>contents of Memory Script:<br>{<br>sql clone \u00abcreate spfile from memory\u00bb;<br>shutdown clone immediate;<br>startup clone nomount;<br>.<br>.<br>shutdown clone immediate;<br>&nbsp;startup clone nomount;<br># mount database<br>sql clone \u2018alter database mount clone database\u2019;<br>}<br>executing Memory Script<br>sql statement: create spfile from memory<br>database closed<br>database dismounted<br>Oracle instance shut down<br>connected to auxiliary database (not started)<br>Oracle instance started<br>.<br>.<br># set requested point in time<br>set until&nbsp; time \u00abto_date(\u201903\/11\/2022 22:14:14\u2032,\u2019dd\/mm\/yyyy hh24:mi:ss\u2019)\u00bb;<br>.<br>:<br>}<br>executing Memory Script<br>executing command: SET until clause<br>executing command: SET NEWNAME<br>Starting restore at 2022-11-03:23:12:30<br>allocated channel: ORA_AUX_DISK_1<br>channel ORA_AUX_DISK_1: SID=182 device type=DISK<br>channel ORA_AUX_DISK_1: starting datafile backup set restore<br>channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set<br>.<br>.<br>.<br>set until&nbsp; time \u00abto_date(\u201903\/11\/2022 22:14:14\u2032,\u2019dd\/mm\/yyyy hh24:mi:ss\u2019)\u00bb;<br># online the datafiles restored or switched<br>sql clone \u2018ORCLPDB1\u2019 \u00abalter database datafile<br>&nbsp;12 online\u00bb;<br># recover and open resetlogs<br>recover clone database tablespace&nbsp; \u00abORCLPDB1\u2033:\u00bbUSERS\u00bb, \u00abSYSTEM\u00bb, \u00abORCLPDB1\u2033:\u00bbSYSTEM\u00bb, \u00abUNDOTBS1\u00bb, \u00abORCLPDB1\u2033:\u00bbUNDOTBS1\u00bb, \u00abSYSAUX\u00bb, \u00abORCLPDB1\u2033:\u00bbSYSAUX\u00bb delete<br>archivelog;<br>alter clone database open resetlogs;<br>}<br>executing Memory Script<br>executing command: SET until clause<br>sql statement: alter database datafile&nbsp; 12 online<br>Starting recover at 2022-11-03:23:12:34<br>using channel ORA_AUX_DISK_1<br>starting media recovery<br>.<br>.<br>archived log file name=\/u01\/app\/oracle\/fast_recovery_area\/ORCLCDB\/archivelog\/2022_11_03\/o1_mf_1_27_kp7zhcqx_.arc thread=1 sequence=27<br>archived log file name=\/u01\/app\/oracle\/fast_recovery_area\/ORCLCDB\/archivelog\/2022_11_03\/o1_mf_1_28_kp8llzrd_.arc thread=1 sequence=28<br>media recovery complete, elapsed time: 00:00:01<br>Finished recover at 2022-11-03:23:12:36<br>database opened<br>contents of Memory Script:<br>{<br>sql clone \u2018alter pluggable database&nbsp; ORCLPDB1 open\u2019;<br>}<br>executing Memory Script<br>sql statement: alter pluggable database&nbsp; ORCLPDB1 open<br>contents of Memory Script:<br>{<br># create directory for datapump import<br>sql \u2018ORCLPDB1\u2019 \u00abcreate or replace directory<br>TSPITR_DIROBJ_DPDIR as \u00bb<br>\/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\u00bb\u00bb;<br># create directory for datapump export<br>sql clone \u2018ORCLPDB1\u2019 \u00abcreate or replace directory<br>TSPITR_DIROBJ_DPDIR as \u00bb<br>\/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\u00bb\u00bb;<br>}<br>executing Memory Script<br>sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as \u00bb\/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\u00bb<br>sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as \u00bb\/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\u00bb<br>Performing export of tables\u2026<br>&nbsp;&nbsp;&nbsp;<strong>EXPDP<\/strong>&gt; Starting \u00abSYS\u00bb.\u00bbTSPITR_EXP_wdum_ssEn\u00bb:&nbsp;<br>&nbsp;&nbsp; EXPDP&gt; Processing object type TABLE_EXPORT\/TABLE\/TABLE_DATA<br>&nbsp;&nbsp; EXPDP&gt; Processing object type TABLE_EXPORT\/TABLE\/STATISTICS\/TABLE_STATISTICS<br>   EXPDP&gt; Processing object type TABLE_EXPORT\/TABLE\/STATISTICS\/MARKER<br>   EXPDP&gt; Processing object type TABLE_EXPORT\/TABLE\/TABLE<br>   EXPDP&gt; . .&nbsp;<strong>exported \u00abRAUL\u00bb.\u00bbUNO\u00bb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5.078 KB&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5 rows<\/strong><br>   EXPDP&gt; Master table \u00abSYS\u00bb.\u00bbTSPITR_EXP_wdum_ssEn\u00bb successfully loaded\/unloaded<br>&nbsp;  EXPDP&gt; ******************************************************************************<br>&nbsp;&nbsp; EXPDP&gt; Dump file set for SYS.TSPITR_EXP_wdum_ssEn is:<br>&nbsp;&nbsp; EXPDP&gt;&nbsp;&nbsp; \/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\/tspitr_wdum_34186.dmp<br>Export completed<br>contents of Memory Script:<br>{<br># shutdown clone before import<br>shutdown clone abort<br>}<br>executing Memory Script<br>Oracle instance shut down<br>Performing import of tables\u2026<br><strong>IMPDP<\/strong>&gt; Master table \u00abSYS\u00bb.\u00bbTSPITR_IMP_wdum_sDFr\u00bb successfully loaded\/unloaded<br><strong>IMPDP&gt;<\/strong>&nbsp;Starting \u00abSYS\u00bb.\u00bbTSPITR_IMP_wdum_sDFr\u00bb:&nbsp;<br>IMPDP&gt; Processing object type TABLE_EXPORT\/TABLE\/TABLE<br>IMPDP&gt; Processing object type TABLE_EXPORT\/TABLE\/TABLE_DATA<br><strong>IMPDP&gt; . . imported \u00abRAUL\u00bb.\u00bbUNO\u00bb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5.078 KB&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5 rows<\/strong><br>IMPDP&gt; Processing object type TABLE_EXPORT\/TABLE\/STATISTICS\/TABLE_STATISTICS<br>MPDP&gt; Job \u00abSYS\u00bb.\u00bbTSPITR_IMP_wdum_sDFr\u00bb successfully completed at Thu Nov 3 23:14:00 2022 elapsed 0 00:00:27<br>import completed<br>Removing automatic instance<br>auxiliary instance file \/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\/ORCLCDB\/8857B36632797E5CE0536210ED0ADAC7\/datafile\/o1_mf_undotbs1_kp8ln8dn_.dbf deleted<br>auxiliary instance file \/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\/ORCLCDB\/datafile\/o1_mf_undotbs1_kp8lmsb6_.dbf deleted<br>Finished recover at 2022-11-03:23:14:04<br><\/p>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Comprobamos que la tabla ha sido restaurada:<\/p>\n\n\n\n<p class=\"has-ast-global-color-8-color has-ast-global-color-4-background-color has-text-color has-background has-small-font-size\">oracle@oracle21c ~]$ sqlplus raul\/***@ORCLPDB1<br>SQL*Plus: Release 19.0.0.0.0 \u2013 Production on Thu Nov 3 23:26:37 2022<br>Version 19.3.0.0.0<br>Copyright (c) 1982, 2019, Oracle.&nbsp; All rights reserved.<br>Last Successful login time: Thu Nov 03 2022 22:26:01 +00:00<br>Connected to:<br>Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 \u2013 Production<br>Version 19.3.0.0.0<br>SQL&gt; SELECT * FROM UNO;<br>DNI<br>\u2014\u2014-<br>1<br>2<br>3<br>4<br>5<\/p>\n\n\n\n<p><strong>RESTAURAR LA TABLA CON OTRO NOMBRE DIFERENTE<\/strong><\/p>\n\n\n\n<p>Existe otra opci\u00f3n muy \u00fatil para restaurar la tabla borrada, es restaurarla con otro nombre o \u201cremap\u201d de tabla.<\/p>\n\n\n\n<p class=\"has-ast-global-color-8-color has-ast-global-color-4-background-color has-text-color has-background has-small-font-size\">RMAN&gt; connect target \/<br>connected to target database: ORCLCDB (DBID=2778750799)<br>RMAN&gt;<strong>&nbsp;@recover_table_remap.bck<\/strong><br>RMAN&gt;<strong>&nbsp;run{<\/strong><br>2&gt;<strong>&nbsp;recover table \u00abRAUL\u00bb.\u00bbUNO\u00bb OF PLUGGABLE DATABASE ORCLPDB1<\/strong><br>3&gt;<strong>&nbsp;until time \u00abto_date(\u201903\/11\/2022 22:14:14\u2032,\u2019dd\/mm\/yyyy hh24:mi:ss\u2019)\u00bb<\/strong><br>4&gt;&nbsp;<strong>AUXILIARY DESTINATION \u2018\/u01\/app\/oracle\/oradata\/ORCLCDBRESTORE\u2019<\/strong><br>5&gt;&nbsp;<strong>REMAP TABLE \u00abRAUL\u00bb.\u00bbUNO\u00bb:\u00bbRAUL\u00bb.\u00bbUNORESTORE\u00bb;<\/strong><br>6&gt;<strong>&nbsp;}<\/strong><br>Starting recover at 2022-11-03:23:40:08<br>using target database control file instead of recovery catalog<br>allocated channel: ORA_DISK_1<br>channel ORA_DISK_1: SID=293 device type=DISK<br>RMAN-05026: warning: presuming following set of tablespaces applies to specified point-in-time<br>List of tablespaces expected to have UNDO segments<br>Tablespace SYSTEM<br>Tablespace ORCLPDB1:SYSTEM<br>{<br>sql clone \u2018alter database mount clone database\u2019;<br># archive current online log<br>sql \u2018alter system archive log current\u2019;<br>}<br>executing Memory Script<br>executing command: SET until clause<br>Starting restore at 2022-11-03:23:40:26<br>allocated channel: ORA_AUX_DISK_1<br>channel ORA_AUX_DISK_1: SID=4 device type=DISK<br>channel ORA_AUX_DISK_1: starting datafile backup set restore<br>channel ORA_AUX_DISK_1: restoring control file<br>channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03<br>Finished restore at 2022-11-03:23:40:51<br><br>datafile 1 switched to datafile copy<br>{<br>.<br>.<br>Finished restore at 2022-11-03:23:42:17<br>Performing export of tables\u2026<br>Oracle instance shut down<br>Performing import of tables\u2026<br>IMPDP&gt; Master table \u00abSYS\u00bb.\u00bbTSPITR_IMP_elEq_vqzl\u00bb successfully loaded\/unloaded<br>IMPDP&gt; Starting \u00abSYS\u00bb.\u00bbTSPITR_IMP_elEq_vqzl\u00bb:&nbsp;<br>IMPDP&gt; . .&nbsp;<strong>imported \u00abRAUL\u00bb.\u00bbUNORESTORE\u00bb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5.078 KB&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5 rows<\/strong><br>.<br>.<br>Import completed<\/p>\n\n\n\n<p>&nbsp;&nbsp;<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>En resumen con esta nueva funcionalidad, evitamos crear una base de datos auxiliary o dummy, exportar la tabla e importarla en la base de datos operativa y luego borrar la base de datos restaurada para este fin. Con este comando, todos los pasos que antiguamente realiz\u00e1bamos a mano, se pueden realizar de forma autom\u00e1tica.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>En la versi\u00f3n 12c, se introdujeron muchas y muy \u00fatiles nuevas funcionalidades. Entre ellas, la posibilidad de recuperar una tabla con RMAN. Esta caracter\u00edstica se aplica tanto a arquitecturas Multitenant como no Multitenant, permiti\u00e9ndote recuperar una tabla de una PDB si ese fuera el caso. En el siguiente enlace podemos encontrar la nota oficial: RMAN<\/p>\n<div class=\"more-link\">\n\t\t\t\t <a href=\"https:\/\/oracleconraul.com\/index.php\/2023\/07\/18\/restore-table-with-rman\/\" class=\"link-btn theme-btn\"><span>Read More <\/span> <i class=\"fa fa-caret-right\"><\/i><\/a>\n\t\t\t<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wpupg_custom_link":[],"wpupg_custom_link_behaviour":[],"wpupg_custom_link_nofollow":[],"wpupg_custom_image":[],"wpupg_custom_image_id":[],"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[14],"tags":[25],"class_list":["post-15","post","type-post","status-publish","format-standard","hentry","category-oracle","tag-restore-backup"],"_links":{"self":[{"href":"https:\/\/oracleconraul.com\/index.php\/wp-json\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oracleconraul.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oracleconraul.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oracleconraul.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oracleconraul.com\/index.php\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":82,"href":"https:\/\/oracleconraul.com\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":4005,"href":"https:\/\/oracleconraul.com\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions\/4005"}],"wp:attachment":[{"href":"https:\/\/oracleconraul.com\/index.php\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oracleconraul.com\/index.php\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oracleconraul.com\/index.php\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}