Retrieve the Table that has been mistakenly dropped/Truncate/Delete on the primary database on the standby Database

Source: Internet
Author: User

Retrieve the Table that has been mistakenly dropped/Truncate/Delete on the primary database on the standby Database

Prerequisites:
- Standby Database Must be in Flashback database mode.  - Time at which Drop/Truncate/Delete Table happened should be within the db_flashback_retention_target and all the flashback and archive logs should be available
 
 
Retrieve the Table that has been mistakenly dropped/Truncate/Delete on the primary database on the secondary uard slave database. refer to the following article: how To Recover From A Drop/Truncate/Delete Table Done On Primary Using Flashback On A Standby Database (Document ID 958557.1) master Database: [oracle @ hosta ~] $ Sqlplus/as sysdbaSQL * Plus: Release 11.1.0.7.0-Production on Fri Jul 31 22:08:19 2015 Copyright (c) 1982,200 8, Oracle. all rights reserved. connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0-ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> select sysdate from dual; SYSDATE---------31-JUL-15SQL> show parameter formatNAME type value- ----------------------------------- -------------------------------------- Log_archive_format string % t _ % s _ % r. dbfnls_date_format stringnls_time_format stringnls_time_tz_format stringnls_timestamp_format invalid string TRUESQL> alter session set NLS_DATE_FORMAT = 'yyyy-MM-DD HH24: MI: ss'; Session altered. SQL> select sysdate from dual; SYSDATE --- ---------------- 2015-07-31 22: 10: 00SQL> select count (*) from scott. test_tab_1; COUNT (*) ---------- 2566SQL> truncate scott. test_tab_1; truncate scott. test_tab_1 * ERROR at line 1: ORA-03290: Invalid truncate command-missing CLUSTER or TABLE keywordSQL> truncate table scott. test_tab_1; Table truncated. SQL> slave Database: SQL> show parameter targetNAME TYPE VALUE ----------------------------------------------- ---------------------------- Archive_lag_target integer 0db_flashback_retention_target integer 1440 -------> the default setting is 1440 minutes, that is, one day. Fast_start_io_target integer 0fast_start_mttr_target integer 0memory_max_target big integer 356Mmemory_target big integer 1_big integer 0sga_target big integer 0SQL> recover managed standby database cancel; Media recovery complete. SQL> shutdown immediate; ORA-01109: database not openDatabase dismounted. ORACLE instance shut down. SQL> startup mount; ORACLE instance started. total System Global Area 372449280 bytesFixed Size 1313484 bytesVariable Size 322962740 bytesDatabase Buffers 41943040 bytesRedo Buffers 6230016 bytesDatabase mounted. SQL> flashback database to timestamp to_date ('2017-07-31 22:10:00 ', 'yyyy-MM-DD HH24: MI: ss '); flashback database to timestamp to_date ('2017-07-31 22:10:00 ', 'yyyy-MM-DD HH24: MI: ss') * ERROR at line 1: ORA-01153: an incompatible media recovery is activeSQL> alter database recover managed standby database cancel; Database altered. SQL> flashback database to timestamp to_date ('2017-07-31 22:10:00 ', 'yyyy-MM-DD HH24: MI: ss'); Flashback complete. SQL> alter database open read only; Database altered. SQL> select count (*) from scott. test_tab_1; COUNT (*) ---------- 2566SQL> exit [oracle @ hostb SBDB1] $ export NLS_LANG = hosts [oracle @ hostb SBDB1] $ exp system/oracle file =/home/oracle/test_tab_exp_0730.dmp tables = scott. test_tab_1Export: Release 11.1.0.7.0-Production on Fri Jul 31 22:20:03 2015 Copyright (c) 1982,200 7, Oracle. all rights reserved. connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0-ProductionWith the Partitioning, OLAP, data Mining and Real Application Testing optionsExport done in AL32UTF8 character set and AL16UTF16 NCHAR character setAbout to export specified tables via Conventional Path... current user changed to SCOTT .. exporting table TEST_TAB_1 2566 rows exportedExport terminated successfully without warnings. [oracle @ hostb SBDB1] $



Slave database:

[oracle@hostb SBDB1]$ sqlplus / as sysdbaSQL*Plus: Release 11.1.0.7.0 - Production on Fri Jul 31 22:26:46 2015Copyright (c) 1982, 2008, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> shutdown immediate Database closed.Database dismounted.ORACLE instance shut down.SQL> startup mount ORACLE instance started.Total System Global Area  372449280 bytesFixed Size                  1313484 bytesVariable Size             322962740 bytesDatabase Buffers           41943040 bytesRedo Buffers                6230016 bytesDatabase mounted.SQL> recover standby database;ORA-00279: change 1156098 generated at 07/31/2015 22:10:03 needed for thread 1ORA-00289: suggestion : /home/oracle/archive/SBDB1/1_100_884907736.dbfORA-00280: change 1156098 for thread 1 is in sequence #100Specify log: {<RET>=suggested | filename | AUTO | CANCEL}AUTOORA-00279: change 1156325 generated at 07/31/2015 22:14:44 needed for thread 1ORA-00289: suggestion : /home/oracle/archive/SBDB1/1_101_884907736.dbfORA-00280: change 1156325 for thread 1 is in sequence #101ORA-00278: log file '/home/oracle/archive/SBDB1/1_100_884907736.dbf' no longerneeded for this recoveryORA-00279: change 1156336 generated at 07/31/2015 22:15:03 needed for thread 1ORA-00289: suggestion : /home/oracle/archive/SBDB1/1_102_884907736.dbfORA-00280: change 1156336 for thread 1 is in sequence #102ORA-00278: log file '/home/oracle/archive/SBDB1/1_101_884907736.dbf' no longerneeded for this recoveryORA-00279: change 1156346 generated at 07/31/2015 22:15:13 needed for thread 1ORA-00289: suggestion : /home/oracle/archive/SBDB1/1_103_884907736.dbfORA-00280: change 1156346 for thread 1 is in sequence #103ORA-00278: log file '/home/oracle/archive/SBDB1/1_102_884907736.dbf' no longerneeded for this recoveryORA-00308: cannot open archived log'/home/oracle/archive/SBDB1/1_103_884907736.dbf'ORA-27037: unable to obtain file statusLinux Error: 2: No such file or directoryAdditional information: 3SQL> alter database recover managed standby database disconnect from session;alter database recover managed standby database disconnect from session*ERROR at line 1:ORA-01153: an incompatible media recovery is activeSQL> alter database recover managed standby database cancel;Database altered.SQL> alter database recover managed standby database  using current logfile disconnect from session;Database altered.SQL>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.