oracle如何恢复被覆盖的存储过程
程序员文章站
2023-11-22 14:47:58
如果你不小心覆盖了之前的存储过程,那得赶紧闪回,时长越长闪回的可能性越小。原理很简单,存储过程的定义就是数据字典,修改数据字典跟修改普通表的数据没有区别,此时会把修改前的内...
如果你不小心覆盖了之前的存储过程,那得赶紧闪回,时长越长闪回的可能性越小。原理很简单,存储过程的定义就是数据字典,修改数据字典跟修改普通表的数据没有区别,此时会把修改前的内容放到undo中,我们可以根据这一点来进行闪回,所以我说要尽快,要不然找不回来了。下面我们来做一个实验:
1.在用户test下14:31下建立存储过程
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下删除存储过程
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;
1.在用户test下14:31下建立存储过程
复制代码 代码如下:
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下删除存储过程
复制代码 代码如下:
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;