Friday 9 August 2019

RMAN - Recovering Tables using RMAN RECOVER Command until time

Senario Preview :

  • Database in archivelog mode
  • No recovery catalog 
  • Rman Backup available
  • 4 tables are drop on particular time. 


Solution :

  • Recover table until time on RMAN prompt utility.
  • Provide auxiliary destination 
  • Got error : disable |drop constraints (not recommnded)
  •  Recover table completed check table data


Error:
There are restriction for constraints while prerforming recover table for m RMAN utility.

I have dissable contraint then perform further operations. 

Recover table from RMAN is suitable only there is no contraint restriction

  • Rman table recovery having limitations on constraints.
  • Got error on parsing 


  • [oracle@srv1 expdp]$ sqlplus soe/soe@smr1

    SQL*Plus: Release 12.1.0.2.0 Production on Thu Aug 8 16:54:32 2019

    Copyright (c) 1982, 2014, Oracle.  All rights reserved.


    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

    SQL> sho user
    USER is "SOE"
    SQL> SELECT TO_CHAR(SYSDATE,'YYYY-MM-DD:HH24:MI:SS') FROM DUAL;
    c
    TO_CHAR(SYSDATE,'YY
    -------------------
    2019-08-08:16:54:46

    SQL> SELECT CUSTOMER_ID FROM SOE.ORDERS WHERE ROWNUM=1;
    SP2-0734: unknown command beginning "cSELECT CU..." - rest of line ignored.
    SQL> SELECT CUSTOMER_ID FROM SOE.ORDERS WHERE ROWNUM=1;

    CUSTOMER_ID
    -----------
              1
    SQL> DELETE ORDER_ITEMS WHERE ORDER_ID IN ( SELECT ORDER_ID FROM ORDERS WHERE CUSTOMER_ID=1);

    88 rows deleted.

    SQL> DELETE FROM ORDERS WHERE CUSTOMER_ID=1;

    37 rows deleted.

    SQL> DELETE FROM ADDRESSES WHERE CUSTOMER_ID=1;

    0 rows deleted.

    SQL> DELETE CUSTOMERS WHERE CUSTOMER_ID=1;

    1 row deleted.

    SQL>  COMMIT;

    Commit complete.

    SQL> ALTER SYSTEM SWITCH LOGFILE;

    System altered.

    SQL>


    [oracle@srv1 2019_08_08]$ rman target /

    Recovery Manager: Release 12.1.0.2.0 - Production on Thu Aug 8 16:43:09 2019

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

    connected to target database: SMR1 (DBID=3409868754)

    RMAN> CREATE USER TUSER IDENTIFIED BY oracle DEFAULT TABLESPACE soetbs QUOTA UNLIMITED ON soetbs;

    using target database control file instead of recovery catalog
    Statement processed

    RMAN> GRANT CONNECT, CREATE TABLE TO TUSER;

    Statement processed

    RMAN> RECOVER TABLE soe.ORDER_ITEMS, soe.ORDERS, soe.ADDRESSES, soe.CUSTOMERS UNTIL TIME "to_date('2019-08-08:16:54:46','YYYY-MM-DD:HH24:MI:SS')" AUXILIARY DESTINATION '/u01/rmanbkp/auxdest/' REMAP TABLE 'SOE'.'ORDER_ITEMS': 'TUSER'.'ORDER_ITEMS_B','SOE'.'ORDERS': 'TUSER'.'ORDERS_B','SOE'.'ADDRESSES':'TUSER'.'ADDRESSES_B','SOE'.'CUSTOMERS':'TUSER'.'CUSTOMERS_B';

    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00558: error encountered while parsing input commands
    RMAN-01009: syntax error: found "dot": expecting one of: "allow, archivelog, auxiliary, check, clear, datapump, delete, dump, exclude, from, from service, noparallel, noredo, notableimport, parallel, preview, remap, restore, section, skip readonly, test, undo, using, validate, colon, comma, ;"
    RMAN-01007: at line 1 column 227 file: standard input

    RMAN> RECOVER TABLE soe.ORDER_ITEMS  UNTIL TIME "to_date('2019-08-08:16:54:46','YYYY-MM-DD:HH24:MI:SS')" AUXILIARY DESTINATION '/u01/rmanbkp/auxdest/' REMAP TABLE 'SOE'.'ORDER_ITEMS':'TUSER.ORDER_ITEMS_B';

    Starting recover at 09-AUG-19
    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='kvlw'

    initialization parameters used for automatic instance:
    db_name=SMR1
    db_unique_name=kvlw_pitr_SMR1
    compatible=12.1.0.2.0
    db_block_size=8192
    db_files=200
    diagnostic_dest=/u01/app/oracle
    _system_trig_enabled=FALSE
    sga_target=1712M
    processes=200
    db_create_file_dest=/u01/rmanbkp/auxdest/
    log_archive_dest_1='location=/u01/rmanbkp/auxdest/'
    #No auxiliary parameter file used


    starting up automatic instance SMR1

    Oracle instance started

    Total System Global Area    1795162112 bytes

    Fixed Size                     2925456 bytes
    Variable Size                436210800 bytes
    Database Buffers            1342177280 bytes
    Redo Buffers                  13848576 bytes
    Automatic instance created

    contents of Memory Script:
    {
    # set requested point in time
    set until  time "to_date('2019-08-08:16:54:46','YYYY-MM-DD:HH24: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 09-AUG-19
    allocated channel: ORA_AUX_DISK_1
    channel ORA_AUX_DISK_1: SID=21 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/rmanbkp/smr1bu8n3ln.bkp
    channel ORA_AUX_DISK_1: piece handle=/u01/rmanbkp/smr1bu8n3ln.bkp tag=TAG20190808T164724
    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/rmanbkp/auxdest/SMR1/controlfile/o1_mf_gntkfb4q_.ctl
    Finished restore at 09-AUG-19

    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('2019-08-08:16:54:46','YYYY-MM-DD:HH24: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 /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_temp_%u_.tmp in control file

    Starting restore at 09-AUG-19
    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/rmanbkp/auxdest/SMR1/datafile/o1_mf_system_%u_.dbf
    channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_undotbs1_%u_.dbf
    channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_sysaux_%u_.dbf
    channel ORA_AUX_DISK_1: reading from backup piece /u01/rmanbkp/smr1au8n3gs.bkp
    channel ORA_AUX_DISK_1: piece handle=/u01/rmanbkp/smr1au8n3gs.bkp tag=TAG20190808T164724
    channel ORA_AUX_DISK_1: restored backup piece 1
    channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05
    Finished restore at 09-AUG-19

    datafile 1 switched to datafile copy
    input datafile copy RECID=13 STAMP=1015861065 file name=/u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_system_gntkfj9y_.dbf
    datafile 4 switched to datafile copy
    input datafile copy RECID=14 STAMP=1015861065 file name=/u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_undotbs1_gntkfjb7_.dbf
    datafile 3 switched to datafile copy
    input datafile copy RECID=15 STAMP=1015861065 file name=/u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_sysaux_gntkfjb4_.dbf

    contents of Memory Script:
    {
    # set requested point in time
    set until  time "to_date('2019-08-08:16:54:46','YYYY-MM-DD:HH24: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 09-AUG-19
    using channel ORA_AUX_DISK_1

    starting media recovery

    archived log for thread 1 with sequence 32 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_32_gnr1m0n5_.arc
    archived log for thread 1 with sequence 33 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_33_gnr1m220_.arc
    archived log for thread 1 with sequence 34 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_34_gnr1rtwj_.arc
    archived log file name=/u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_32_gnr1m0n5_.arc thread=1 sequence=32
    archived log file name=/u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_33_gnr1m220_.arc thread=1 sequence=33
    archived log file name=/u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_34_gnr1rtwj_.arc thread=1 sequence=34
    media recovery complete, elapsed time: 00:00:00
    Finished recover at 09-AUG-19

    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/rmanbkp/auxdest/SMR1/controlfile/o1_mf_gntkfb4q_.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    1795162112 bytes

    Fixed Size                     2925456 bytes
    Variable Size                452988016 bytes
    Database Buffers            1325400064 bytes
    Redo Buffers                  13848576 bytes

    sql statement: alter system set  control_files =   ''/u01/rmanbkp/auxdest/SMR1/controlfile/o1_mf_gntkfb4q_.ctl'' comment= ''RMAN set'' scope=spfile

    Oracle instance shut down

    connected to auxiliary database (not started)
    Oracle instance started

    Total System Global Area    1795162112 bytes

    Fixed Size                     2925456 bytes
    Variable Size                452988016 bytes
    Database Buffers            1325400064 bytes
    Redo Buffers                  13848576 bytes

    sql statement: alter database mount clone database

    contents of Memory Script:
    {
    # set requested point in time
    set until  time "to_date('2019-08-08:16:54:46','YYYY-MM-DD:HH24:MI:SS')";
    # set destinations for recovery set and auxiliary set datafiles
    set newname for datafile  8 to new;
    # restore the tablespaces in the recovery set and the auxiliary set
    restore clone datafile  8;

    switch clone datafile all;
    }
    executing Memory Script

    executing command: SET until clause

    executing command: SET NEWNAME

    Starting restore at 09-AUG-19
    allocated channel: ORA_AUX_DISK_1
    channel ORA_AUX_DISK_1: SID=21 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 00008 to /u01/rmanbkp/auxdest/KVLW_PITR_SMR1/datafile/o1_mf_soetbs_%u_.dbf
    channel ORA_AUX_DISK_1: reading from backup piece /u01/rmanbkp/smr1au8n3gs.bkp
    channel ORA_AUX_DISK_1: piece handle=/u01/rmanbkp/smr1au8n3gs.bkp tag=TAG20190808T164724
    channel ORA_AUX_DISK_1: restored backup piece 1
    channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:55
    Finished restore at 09-AUG-19

    datafile 8 switched to datafile copy
    input datafile copy RECID=17 STAMP=1015861231 file name=/u01/rmanbkp/auxdest/KVLW_PITR_SMR1/datafile/o1_mf_soetbs_gntkk4gq_.dbf

    contents of Memory Script:
    {
    # set requested point in time
    set until  time "to_date('2019-08-08:16:54:46','YYYY-MM-DD:HH24:MI:SS')";
    # online the datafiles restored or switched
    sql clone "alter database datafile  8 online";
    # recover and open resetlogs
    recover clone database tablespace  "SOETBS", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;
    alter clone database open resetlogs;
    }
    executing Memory Script

    executing command: SET until clause

    sql statement: alter database datafile  8 online

    Starting recover at 09-AUG-19
    using channel ORA_AUX_DISK_1

    starting media recovery

    archived log for thread 1 with sequence 32 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_32_gnr1m0n5_.arc
    archived log for thread 1 with sequence 33 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_33_gnr1m220_.arc
    archived log for thread 1 with sequence 34 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_34_gnr1rtwj_.arc
    archived log file name=/u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_32_gnr1m0n5_.arc thread=1 sequence=32
    archived log file name=/u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_33_gnr1m220_.arc thread=1 sequence=33
    archived log file name=/u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_34_gnr1rtwj_.arc thread=1 sequence=34
    media recovery complete, elapsed time: 00:00:00
    Finished recover at 09-AUG-19

    database opened

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

    sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01/rmanbkp/auxdest/''

    sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01/rmanbkp/auxdest/''

    Performing export of tables...
       EXPDP> Starting "SYS"."TSPITR_EXP_kvlw_ieza":
       EXPDP> Estimate in progress using BLOCKS method...
       EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
       EXPDP> Total estimation using BLOCKS method: 208 MB
       EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
       EXPDP> Processing object type TABLE_EXPORT/TABLE/IDENTITY_COLUMN
       EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
       EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
       EXPDP> . . exported "SOE"."ORDER_ITEMS"                         170.4 MB 3735896 rows
       EXPDP> Master table "SYS"."TSPITR_EXP_kvlw_ieza" successfully loaded/unloaded
       EXPDP> ******************************************************************************
       EXPDP> Dump file set for SYS.TSPITR_EXP_kvlw_ieza is:
       EXPDP>   /u01/rmanbkp/auxdest/tspitr_kvlw_36316.dmp
       EXPDP> Job "SYS"."TSPITR_EXP_kvlw_ieza" successfully completed at Fri Aug 9 15:41:41 2019 elapsed 0 00:00:37
    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_kvlw_ptre" successfully loaded/unloaded
       IMPDP> Starting "SYS"."TSPITR_IMP_kvlw_ptre":
       IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
       IMPDP> ORA-39083: Object type TABLE:"SOE"."TUSER.ORDER_ITEMS_B" failed to create with error:
    ORA-02264: name already used by an existing constraint
    Failing sql is:
    CREATE TABLE "SOE"."TUSER.ORDER_ITEMS_B" ("ORDER_ID" NUMBER(12,0) CONSTRAINT "OI_ORDER_ID_NN" NOT NULL ENABLE, "LINE_ITEM_ID" NUMBER(3,0) CONSTRAINT "OI_LINEITEM_ID_NN" NOT NULL ENABLE, "PRODUCT_ID" NUMBER(6,0) CONSTRAINT "OI_PRODUCT_ID_NN" NOT NULL ENABLE, "UNIT_PRICE" NUMBER(8,2), "QUANTITY" NUMBER(8,0), "DISPATCH_DATE" DATE, "RETURN_DATE" DATE, "GIFT
       IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
       IMPDP> Processing object type TABLE_EXPORT/TABLE/IDENTITY_COLUMN
       IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
       IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
       IMPDP> Job "SYS"."TSPITR_IMP_kvlw_ptre" completed with 1 error(s) at Fri Aug 9 15:41:46 2019 elapsed 0 00:00:03
    import completed with errors; Oracle Data Pump dump file tspitr_kvlw_36316.dmp is retained

    Removing automatic instance
    Automatic instance removed
    auxiliary instance file /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_temp_gntkhmst_.tmp deleted
    auxiliary instance file /u01/rmanbkp/auxdest/KVLW_PITR_SMR1/onlinelog/o1_mf_3_gntknthw_.log deleted
    auxiliary instance file /u01/rmanbkp/auxdest/KVLW_PITR_SMR1/onlinelog/o1_mf_2_gntknsbj_.log deleted
    auxiliary instance file /u01/rmanbkp/auxdest/KVLW_PITR_SMR1/onlinelog/o1_mf_1_gntknrjl_.log deleted
    auxiliary instance file /u01/rmanbkp/auxdest/KVLW_PITR_SMR1/datafile/o1_mf_soetbs_gntkk4gq_.dbf deleted
    auxiliary instance file /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_sysaux_gntkfjb4_.dbf deleted
    auxiliary instance file /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_undotbs1_gntkfjb7_.dbf deleted
    auxiliary instance file /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_system_gntkfj9y_.dbf deleted
    auxiliary instance file /u01/rmanbkp/auxdest/SMR1/controlfile/o1_mf_gntkfb4q_.ctl deleted
    Finished recover at 09-AUG-19

    RMAN>
    #################################################################

    There are restriction for constraints while prerforming recover table for m RMAN utility.

    I have dissable contraint then perform further operations. 

    Recover table from RMAN is suitable only there is no contraint restriction

    RMAN> RECOVER TABLE soe.ORDER_ITEMS, soe.ORDERS, soe.ADDRESSES, soe.CUSTOMERS UNTIL TIME "to_date('2019-08-08:16:54:46','YYYY-MM-DD:HH24:MI:SS')" AUXILIARY DESTINATION '/u01/rmanbkp/auxdest/' REMAP TABLE 'SOE'.'ORDER_ITEMS':'ORDER_ITEMS_B','SOE'.'ORDERS':'ORDERS_B','SOE'.'ADDRESSES':'ADDRESSES_B','SOE'.'CUSTOMERS':'CUSTOMERS_B';

    Starting recover at 09-AUG-19
    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='EkEB'

    initialization parameters used for automatic instance:
    db_name=SMR1
    db_unique_name=EkEB_pitr_SMR1
    compatible=12.1.0.2.0
    db_block_size=8192
    db_files=200
    diagnostic_dest=/u01/app/oracle
    _system_trig_enabled=FALSE
    sga_target=1712M
    processes=200
    db_create_file_dest=/u01/rmanbkp/auxdest/
    log_archive_dest_1='location=/u01/rmanbkp/auxdest/'
    #No auxiliary parameter file used


    starting up automatic instance SMR1

    Oracle instance started

    Total System Global Area    1795162112 bytes

    Fixed Size                     2925456 bytes
    Variable Size                436210800 bytes
    Database Buffers            1342177280 bytes
    Redo Buffers                  13848576 bytes
    Automatic instance created

    contents of Memory Script:
    {
    # set requested point in time
    set until  time "to_date('2019-08-08:16:54:46','YYYY-MM-DD:HH24: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 09-AUG-19
    allocated channel: ORA_AUX_DISK_1
    channel ORA_AUX_DISK_1: SID=21 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/rmanbkp/smr1bu8n3ln.bkp
    channel ORA_AUX_DISK_1: piece handle=/u01/rmanbkp/smr1bu8n3ln.bkp tag=TAG20190808T164724
    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/rmanbkp/auxdest/SMR1/controlfile/o1_mf_gntoc780_.ctl
    Finished restore at 09-AUG-19

    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('2019-08-08:16:54:46','YYYY-MM-DD:HH24: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 /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_temp_%u_.tmp in control file

    Starting restore at 09-AUG-19
    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/rmanbkp/auxdest/SMR1/datafile/o1_mf_system_%u_.dbf
    channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_undotbs1_%u_.dbf
    channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_sysaux_%u_.dbf
    channel ORA_AUX_DISK_1: reading from backup piece /u01/rmanbkp/smr1au8n3gs.bkp
    channel ORA_AUX_DISK_1: piece handle=/u01/rmanbkp/smr1au8n3gs.bkp tag=TAG20190808T164724
    channel ORA_AUX_DISK_1: restored backup piece 1
    channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05
    Finished restore at 09-AUG-19

    datafile 1 switched to datafile copy
    input datafile copy RECID=13 STAMP=1015865094 file name=/u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_system_gntocfgn_.dbf
    datafile 4 switched to datafile copy
    input datafile copy RECID=14 STAMP=1015865094 file name=/u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_undotbs1_gntocfh4_.dbf
    datafile 3 switched to datafile copy
    input datafile copy RECID=15 STAMP=1015865094 file name=/u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_sysaux_gntocfh0_.dbf

    contents of Memory Script:
    {
    # set requested point in time
    set until  time "to_date('2019-08-08:16:54:46','YYYY-MM-DD:HH24: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 09-AUG-19
    using channel ORA_AUX_DISK_1

    starting media recovery

    archived log for thread 1 with sequence 32 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_32_gnr1m0n5_.arc
    archived log for thread 1 with sequence 33 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_33_gnr1m220_.arc
    archived log for thread 1 with sequence 34 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_34_gnr1rtwj_.arc
    archived log file name=/u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_32_gnr1m0n5_.arc thread=1 sequence=32
    archived log file name=/u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_33_gnr1m220_.arc thread=1 sequence=33
    archived log file name=/u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_34_gnr1rtwj_.arc thread=1 sequence=34
    media recovery complete, elapsed time: 00:00:01
    Finished recover at 09-AUG-19

    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/rmanbkp/auxdest/SMR1/controlfile/o1_mf_gntoc780_.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    1795162112 bytes

    Fixed Size                     2925456 bytes
    Variable Size                452988016 bytes
    Database Buffers            1325400064 bytes
    Redo Buffers                  13848576 bytes

    sql statement: alter system set  control_files =   ''/u01/rmanbkp/auxdest/SMR1/controlfile/o1_mf_gntoc780_.ctl'' comment= ''RMAN set'' scope=spfile

    Oracle instance shut down

    connected to auxiliary database (not started)
    Oracle instance started

    Total System Global Area    1795162112 bytes

    Fixed Size                     2925456 bytes
    Variable Size                452988016 bytes
    Database Buffers            1325400064 bytes
    Redo Buffers                  13848576 bytes

    sql statement: alter database mount clone database

    contents of Memory Script:
    {
    # set requested point in time
    set until  time "to_date('2019-08-08:16:54:46','YYYY-MM-DD:HH24:MI:SS')";
    # set destinations for recovery set and auxiliary set datafiles
    set newname for datafile  8 to new;
    # restore the tablespaces in the recovery set and the auxiliary set
    restore clone datafile  8;

    switch clone datafile all;
    }
    executing Memory Script

    executing command: SET until clause

    executing command: SET NEWNAME

    Starting restore at 09-AUG-19
    allocated channel: ORA_AUX_DISK_1
    channel ORA_AUX_DISK_1: SID=21 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 00008 to /u01/rmanbkp/auxdest/EKEB_PITR_SMR1/datafile/o1_mf_soetbs_%u_.dbf
    channel ORA_AUX_DISK_1: reading from backup piece /u01/rmanbkp/smr1au8n3gs.bkp
    channel ORA_AUX_DISK_1: piece handle=/u01/rmanbkp/smr1au8n3gs.bkp tag=TAG20190808T164724
    channel ORA_AUX_DISK_1: restored backup piece 1
    channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:16
    Finished restore at 09-AUG-19

    datafile 8 switched to datafile copy
    input datafile copy RECID=17 STAMP=1015865283 file name=/u01/rmanbkp/auxdest/EKEB_PITR_SMR1/datafile/o1_mf_soetbs_gntoh40l_.dbf

    contents of Memory Script:
    {
    # set requested point in time
    set until  time "to_date('2019-08-08:16:54:46','YYYY-MM-DD:HH24:MI:SS')";
    # online the datafiles restored or switched
    sql clone "alter database datafile  8 online";
    # recover and open resetlogs
    recover clone database tablespace  "SOETBS", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;
    alter clone database open resetlogs;
    }
    executing Memory Script

    executing command: SET until clause

    sql statement: alter database datafile  8 online

    Starting recover at 09-AUG-19
    using channel ORA_AUX_DISK_1

    starting media recovery

    archived log for thread 1 with sequence 32 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_32_gnr1m0n5_.arc
    archived log for thread 1 with sequence 33 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_33_gnr1m220_.arc
    archived log for thread 1 with sequence 34 is already on disk as file /u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_34_gnr1rtwj_.arc
    archived log file name=/u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_32_gnr1m0n5_.arc thread=1 sequence=32
    archived log file name=/u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_33_gnr1m220_.arc thread=1 sequence=33
    archived log file name=/u01/app/oracle/fast_recovery_area/SMR1/archivelog/2019_08_08/o1_mf_1_34_gnr1rtwj_.arc thread=1 sequence=34
    media recovery complete, elapsed time: 00:00:01
    Finished recover at 09-AUG-19

    database opened

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

    sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01/rmanbkp/auxdest/''

    sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01/rmanbkp/auxdest/''

    Performing export of tables...
       EXPDP> Starting "SYS"."TSPITR_EXP_EkEB_avgr":
       EXPDP> Estimate in progress using BLOCKS method...
       EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
       EXPDP> Total estimation using BLOCKS method: 368 MB
       EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
       EXPDP> Processing object type TABLE_EXPORT/TABLE/IDENTITY_COLUMN
       EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
       EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
       EXPDP> . . exported "SOE"."ORDER_ITEMS"                         170.4 MB 3735896 rows
       EXPDP> . . exported "SOE"."ORDERS"                              114.9 MB 1352070 rows
       EXPDP> . . exported "SOE"."ADDRESSES"                           4.084 MB   55703 rows
       EXPDP> . . exported "SOE"."CUSTOMERS"                           4.983 MB   45703 rows
       EXPDP> Master table "SYS"."TSPITR_EXP_EkEB_avgr" successfully loaded/unloaded
       EXPDP> ******************************************************************************
       EXPDP> Dump file set for SYS.TSPITR_EXP_EkEB_avgr is:
       EXPDP>   /u01/rmanbkp/auxdest/tspitr_EkEB_49754.dmp
       EXPDP> Job "SYS"."TSPITR_EXP_EkEB_avgr" successfully completed at Fri Aug 9 16:49:40 2019 elapsed 0 00:01:05
    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_EkEB_lqqt" successfully loaded/unloaded
       IMPDP> Starting "SYS"."TSPITR_IMP_EkEB_lqqt":
       IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
       IMPDP> ORA-39083: Object type TABLE:"SOE"."ORDER_ITEMS_B" failed to create with error:
    ORA-02264: name already used by an existing constraint
    Failing sql is:
    CREATE TABLE "SOE"."ORDER_ITEMS_B" ("ORDER_ID" NUMBER(12,0) CONSTRAINT "OI_ORDER_ID_NN" NOT NULL ENABLE, "LINE_ITEM_ID" NUMBER(3,0) CONSTRAINT "OI_LINEITEM_ID_NN" NOT NULL ENABLE, "PRODUCT_ID" NUMBER(6,0) CONSTRAINT "OI_PRODUCT_ID_NN" NOT NULL ENABLE, "UNIT_PRICE" NUMBER(8,2), "QUANTITY" NUMBER(8,0), "DISPATCH_DATE" DATE, "RETURN_DATE" DATE, "GIFT_WRAP" VARCH
       IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
       IMPDP> . . imported "SOE"."ORDERS_B"                            114.9 MB 1352070 rows
       IMPDP> . . imported "SOE"."ADDRESSES_B"                         4.084 MB   55703 rows
       IMPDP> . . imported "SOE"."CUSTOMERS_B"                         4.983 MB   45703 rows
       IMPDP> Processing object type TABLE_EXPORT/TABLE/IDENTITY_COLUMN
       IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
       IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
       IMPDP> Job "SYS"."TSPITR_IMP_EkEB_lqqt" completed with 1 error(s) at Fri Aug 9 16:49:57 2019 elapsed 0 00:00:13
    import completed with errors; Oracle Data Pump dump file tspitr_EkEB_49754.dmp is retained

    Removing automatic instance
    Automatic instance removed
    auxiliary instance file /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_temp_gntofkky_.tmp deleted
    auxiliary instance file /u01/rmanbkp/auxdest/EKEB_PITR_SMR1/onlinelog/o1_mf_3_gntomg6h_.log deleted
    auxiliary instance file /u01/rmanbkp/auxdest/EKEB_PITR_SMR1/onlinelog/o1_mf_2_gntomf35_.log deleted
    auxiliary instance file /u01/rmanbkp/auxdest/EKEB_PITR_SMR1/onlinelog/o1_mf_1_gntomd68_.log deleted
    auxiliary instance file /u01/rmanbkp/auxdest/EKEB_PITR_SMR1/datafile/o1_mf_soetbs_gntoh40l_.dbf deleted
    auxiliary instance file /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_sysaux_gntocfh0_.dbf deleted
    auxiliary instance file /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_undotbs1_gntocfh4_.dbf deleted
    auxiliary instance file /u01/rmanbkp/auxdest/SMR1/datafile/o1_mf_system_gntocfgn_.dbf deleted
    auxiliary instance file /u01/rmanbkp/auxdest/SMR1/controlfile/o1_mf_gntoc780_.ctl deleted
    Finished recover at 09-AUG-19
    RMAN>


    SQL> show user
    USER is "SOE"
    SQL> select count(*) from ORDER_ITEMS_B;

      COUNT(*)
    ----------
       3735896

    SQL> select count(*) from ADDRESSES_B;

      COUNT(*)
    ----------
         55703

    SQL> select count(*) from ORDERS_B;

      COUNT(*)
    ----------
       1352070

    SQL> select count(*) from CUSTOMERS_B;

      COUNT(*)
    ----------
         45703

    SQL>
    SQL> SELECT COUNT(*) FROM SOE.ORDER_ITEMS_B WHERE ORDER_ID IN ( SELECT ORDER_ID FROM SOE.ORDERS_B WHERE CUSTOMER_ID=1);

      COUNT(*)
    ----------
            88


    SQL> SELECT COUNT(*) FROM SOE.ORDERS_B WHERE CUSTOMER_ID=1;

      COUNT(*)
    ----------
            37

    SQL> SELECT COUNT(*) FROM SOE.ADDRESSES_B WHERE CUSTOMER_ID=1;

      COUNT(*)
    ----------
             0

    SQL> SELECT COUNT(*) FROM SOE.CUSTOMERS_B WHERE CUSTOMER_ID=1;

      COUNT(*)
    ----------
             1

    SQL>

    No comments:

    Post a Comment