Oracle Flash back mechanism

Source: Internet
Author: User

  When I learned Oracle recently, I inadvertently saw Oracle's flashback technology flashback, when Oracle was deleting data or dropping, not directly deleted, but like Windows. Put the data into the Recycle Bin first.

Select *  from User_recyclebin

  You can see the user_recyclebin, you can see the recently deleted table and the index, as follows:

  

  Let's test it with an example: delete the table data and test whether the data can be recovered.

Select *  from TESTEMP1

  The initial data is as follows:

  

  Now let's delete the deptno=10 data, as follows:

Delete  from where deptno=ten

  View the data as follows:

  

  Now that the data has been deleted, we use Oracle's flashback technology for recovery, as follows:

(1) Turn on the line movement function, otherwise error, as follows:

    

Alter Table TESTEMP1 Enable row movement

(2) Perform the flashback operation as follows:

Flashback  Tabletotimestamp to_timestamp ('2017/5/31 16:15:52 ','yyyy-mm-dd hh24:mi:ss');

 (3) View the table data as follows:

  

  Below we directly delete the table drop, as follows: Delete the table and test whether the table is recoverable.

Drop Table TESTEMP1

  View TESTEMP1, error as follows:

  

  (2) Check the Trash bin as follows: There is a drop record.

SELECT * from User_recyclebin ORDER BY droptime Desc

  

 (3) Perform the flashback as follows: The deleted form is resumed.

Table  to Drop

  Let's delete the structure of the table, delete a list of Sal, then test the table structure and whether the data can be recovered? as follows:

  

  Look at the Recycle Bin and discover that there are no records, as follows:

  

  Perform a flashback SQL error as follows:

Table  to timestamp to_timestamp ('2017-05-31 16:40:00','yyyy-mm-dd Hh24:mi:ss');

  

  Summary: Oracle's flashback functionality allows you to recover data if you delete data or drop table directly. Using Flashback is unrecoverable if you delete the table structure, or if you perform a delete table structure after deleting the data first . In addition, the use of the drop table table name purge or TRUNCATE table name cannot be recovered, as these two operations do not put data into the Recycle Bin but are deleted directly.

Oracle Flash back mechanism

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.