如果你不小心覆蓋了之前的存儲(chǔ)過(guò)程,那得趕緊閃回,時(shí)長(zhǎng)越長(zhǎng)閃回的可能性越小,下面為大家介紹下恢復(fù)原理
如果你不小心覆蓋了之前的存儲(chǔ)過(guò)程,那得趕緊閃回,時(shí)長(zhǎng)越長(zhǎng)閃回的可能性越小。原理很簡(jiǎn)單,存儲(chǔ)過(guò)程的定義就是數(shù)據(jù)字典,修改數(shù)據(jù)字典跟修改普通表的數(shù)據(jù)沒(méi)有區(qū)別,此時(shí)會(huì)把修改前的內(nèi)容放到undo中,我們可以根據(jù)這一點(diǎn)來(lái)進(jìn)行閃回,所以我說(shuō)要盡快,要不然找不回來(lái)了。下面我們來(lái)做一個(gè)實(shí)驗(yàn):
1.在用戶TEST下14:31下建立存儲(chǔ)過(guò)程
代碼如下:
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.在用戶TEST下在14:33下刪除存儲(chǔ)過(guò)程
代碼如下:
drop procedure GG_TEST;
3.登錄到sys賬戶下
代碼如下:
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;
更多信息請(qǐng)查看IT技術(shù)專(zhuān)欄