How Oracle restores overwritten stored procedures

Source: Internet
Author: User

If you accidentally overwrite the previous stored procedure, that must quickly flash back, the longer the likelihood of flash back less, the following for you to introduce the principle of recovery

If you accidentally overwrite the previous stored procedure, then flash back and the likelihood of a long, long flashback is smaller. The principle is very simple, the definition of stored procedures is a data dictionary, modify the data dictionary and modify the normal table data no difference, at this time will be the contents of the change before the undo, we can according to this point to flash back, so I said to be as soon as possible, or can not find back. Now let's do an experiment:

1. Create a stored procedure under user test under 14:31

The code is as follows:

Create or replace procedure Gg_test

as l_cnt number;

Begin

For I in 1. 10000

Loop

Execute immediate ' SELECT COUNT (*) from t where x = ' | | I into l_cnt;

End Loop;

End

2. Delete stored procedure under user test at 14:33

The code is as follows:

drop procedure Gg_test;

3. Log in to the SYS account

Copy code code as follows:

CREATE TABLE P_temp as

SELECT *

From Dba_source as of timestamp to_timestamp (' 2014-05-04 14:33:00 ', ' yyyy-mm-dd HH24:MI:SS ')

where TYPE = ' PROCEDURE '

and owner = ' TEST '

and Name = ' gg_test ';

Select text

From P_temp

where name like Upper ('%gg_test% ')

and owner = ' TEST '

Order by line;

TEXT

---------------------------------------------------------------------------

Procedure Gg_test

as l_cnt number;

Begin

For I in 1. 10000

Loop

Execute immediate ' SELECT COUNT (*) from t where x = ' | | I into l_cnt;

End Loop;

End

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.