I deleted the database by mistake. The boss was very upset. I had to recover the database within 30 minutes. In a hurry, I wrote a stored procedure, which is suitable for deleting the table on the day of recovery without remembering the table name.
You only need to input the time of the current day, and then call it.
- The stored procedure is as follows:
- Create Or Replace ProcedureProc_databack (deletetimeInVarchar2)
- As
- -- Query information deleted on the current day and put it into the cursor
- CursorMycursorIs(SelectObject_nameFromRecyclebinWhereDroptimeLikeDeletetime );
- Temp_emp varchar2 (2000 );
- Vflash_back varchar2 (2000 );
- Begin
- OpenMycursor;
- Loop
- FetchMycursorIntoTemp_emp;
- ExitWhenMycursor % notfound;
- -- Build recovery statement
- Vflash_back: ='Flashback table "'| Temp_emp |'"To before drop';
- -- Restores the deleted table cyclically until all the tables are restored.
- ExecuteImmediate vflash_back;
- EndLoop;
- CloseMycursor;
- End;
- -- Call a stored procedure
- -- For example, if today is 2011-12-02, the statement is as follows:
- /*
- Declare
- TimeVarchar2 (20 );
- Begin
- Time: ='2017-12-2011';
- Proc_databack (Time);
- End;
- */