Oracle 10 Gb error data deletion or table flash back function helps you... Flash back operation example

Source: Internet
Author: User
Flash back Query
(1). Flash back Query
For example:
1) after the employee Smith record is deleted, You can query the data of EMP at '2017-02-11 23:34:05 'if you want to query the values before the row record is deleted. The query method is as follows:
  1. select * from emp as of timestamp to_timestamp('2007-02-11 23:34:05','yyyy-mm-dd hh24:mi:ss') where ename='SMITH';  
2) query the current time
alter session set nls_date_format='yyyy-mm-dd hh24:mi;ss';  select sysdate from dual;  
delete from emp;
commit;
  1. Select * from EMP as of Timestamp to_timestamp ('2017-02-11 23:34:05 ', 'yyyy-mm-dd hh24: MI: ss ');
You can re-insert the flash data to the table:
insert into empbak (select * from empbak as of timestamp to_timestamp('2007-02-11 23:34:05','yyyy-mm-dd hh24:mi:ss'));  

(2). Table Flashback
You must have the flash any table permission to perform the following operations on the table:

  1. alter table empbak enable row movement;  

Perform the flash back operation

  1. flashback table emp to timestamp to_timestamp('2007-02-11 23:34:05','yyyy-mm-dd hh24:mi:ss');  

Note: If the table structure changes, there is no way to flash back.
(3). Delete Flashback
Deleting flashback provides a security mechanism for deleting database entities in Oracle10g. When you delete a table, Oracle10g places the table in the recycle bin, and the objects in the recycle bin are actually retained, they will not be deleted until the user decides to permanently delete them or the tablespace space is insufficient. The recycle bin is a virtual container used to store all deleted objects. The dropped column in The user_tables data dictionary indicates the table to be deleted. The query method is as follows:

  1. select table_name,dropped from user_tables;  

You can also use the show command to display the recycle bin information.

  1. sql>show recyclebin  

Or query the data dictionary user_recyclebin to obtain the recycle bin information.

  1. SQL> select object_name,original_name,type,droptime from user_recyclebin;  

For example, restore the deleted table EMP.

  1. SQL>flashback table emp to before drop;  

If you do not know the original table name, you can use the recycle bin name to flash back.

  1. SQL>flashback table "Bin$DSbdfd4rdfdfdfegdfsf==$0" to before drop;  

You can change the table name while recycling:

  1. SQL>flashback table "Bin$DSbdfd4rdfdfdfegdfsf==$0" to before drop rename to emp1;  

To delete a table without entering the recycle bin, you can add the purge option when deleting the table. For example, you can delete the EMP table completely.

  1. SQL>drop table emp purge;  

You can also permanently delete a table by deleting the recyclebin region.

  1. drop table emp cascade constraints  
 
  1. SQL>purge table emp; 


     

Delete the recycle bin of the current user

  1. SQL>purge recyclebin;  

Delete the data of all users in the recycle bin.

  1. SQL>purge dba_recyclebin  
(4). Database flash back
The database flashback function enables the database to return to a previous state. The syntax is as follows:

SQL>alter database flashback on  
SQL>flashback database to scn 46963;
SQL>flashback database to timestamp to_timestamp('2007-2-12 12:00:00','yyyy-mm-dd hh24:mi:ss');
Flash back of data deletion in the table .,,,,, 1. Run ------ cmd -------- 2. c: \ Documents and Settings \ Administrator> sqlplus press Enter 3. Enter the User name: FW/fw @ oradb22 (the username/password of the database to be flashed back) 4,

SQL> ALTER TABLE pr_project enable row movement; (modify the table attributes .) 5,

SQL> flashback table pr_project to timestamp to_timestamp ('2017-11-07 11:20:00 ', 'yyyy-mm-dd hh24: MI: ss'); flashback example: http://blog.csdn.net/zftang/article/details/6388520

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.