Use log mining to restore accidentally deleted tables, data, and views from incomplete Oracle recovery

Source: Internet
Author: User

Use log mining to restore accidentally deleted tables, data, and views from incomplete Oracle recovery

  1. /*--------------------------
  2. Prerequisites:
  3. 1. DB works in archive mode;
  4. 2. Prepare cold data files;
  5. ---------------------------*/
 
  1. Col scriptForA80
  2. Col SQL _REDOForA80
  3. -- Concatenate the statement where to dig
  4. Select 'Exec dbms_logmnr.add_logfile ('''| Member |''')' AsScriptFromV $ logfile;
  5. -- Where to dig
  6. ExecDbms_logmnr.add_logfile ('/Oracle/oradata/orcl_new/redo03.log');
  7. ExecDbms_logmnr.add_logfile ('/Oracle/oradata/orcl_new/redo02.log');
  8. ExecDbms_logmnr.add_logfile ('/Oracle/oradata/orcl_new/redo01.log');
  9. -- Start digging
  10. ExecDbms_logmnr.start_logmnr;
  11. -- Find the result --> the timestamp of the statement to be restored;
  12. SelectScn, SQL _redoFromV $ logmnr_contentsWhereSQL _redoLike 'Drop table emp %';
  13. SCN SQL _REDO
  14. ------------------------------------------------------------------------------------------
  15. 1036547Drop TableT1 purge;
  16. 1037333Drop TableScott. emp purge;
  17. -- 1037333 --> timestamp to be restored
  18. -- Disable DB
  19. Shutdown abort
  20. -- Copy the cold backup file-*. dbf to the data file directory and overwrite it; because the data in the table space such as sys and user should be redone once using logs;
  21. [Oracle @ OracleWeblogic orcl_new_bk] $ cp *. dbf ../orcl_new/
  22. -- Start to mount;
  23. Startup mount
  24. -- Restore to the time point of 1037333 drop table scott. emp purge;
  25. -- Requirement: trc
  26. RecoverDatabaseUntil change 1035742;
  27. -- Start DB in resetlogs;
  28. Alter Database OpenResetlogs;
  29. Principle
  30. 1. The cold backup data file *. dbf is older than the current one, so the scn of the data file must be smaller than the current one;
  31. 2. Use the log mining method to find the scn for table deletion in the log;
  32. 3. In the database shutdown state, use the cold backup data file *. dbf to overwrite the current *. dbf file;-- Ensure data file integrity
  33. 4. Start DB to mount and restore to the time point of log mining (redo the data file once using logs)
  34. 5. resetlogOpen --- The previous logs are overwritten;
  35. PS: the database has four statuses: shutdown, nomount, mount,Open
  36. Shutdown refers to the shutdown status.
  37. Nomount indicates that the Root parameter file has constructed the instance status.
  38. Mount refers to opening the control file for the instance and reading the relevant information in the control file, but not verifying
  39. OpenIt is used to verify the relevant files. If there is no problem, open the file so that users can access it.

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.