Restore deleted data on the current day

Source: Internet
Author: User

 

In December 2, I deleted the database by mistake. The boss was so upset that I would recover the database within 30 minutes. In a hurry, I wrote a stored procedure, this method is applicable when the table is deleted on the day of restoration without remembering the table name.

 

You only need to input the time of the current day, and then call it.

 

SQL code

The stored procedure is as follows:

Create or replace procedure proc_databack (deletetime in varchar2)

As

-- Query information deleted on the current day and put it into the cursor

Cursor mycursor is (select object_name from recyclebin where droptime like deletetime );

Temp_emp varchar2 (2000 );

Vflash_back varchar2 (2000 );

Begin

Open mycursor;

Loop

Fetch mycursor into temp_emp;

Exit when mycursor % notfound;

-- Build recovery statement

Vflash_back: = 'flashback table "'| temp_emp |'" to before drop ';

-- Restores the deleted table cyclically until all the tables are restored.

Execute immediate vflash_back;

End loop;

Close mycursor;

End;

 

-- Call a stored procedure

-- For example, if today is 2011-12-02, the statement is as follows:

/*

Declare

Time varchar2 (20 );

Begin

Time: = '2014-12-2011 ';

Proc_databack (time );

End;

*/

 

From FEP baby

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.