Oracle闪回方式找回存储过程

1、检查当前用户
SQL> show user
USER is “RAY”

2、创建存储过程

create or replace procedure proc_test1 is
begin
  dbms_output.put_line('hello'); 
end;
/

3、模拟误操作覆盖存储过程

create or replace procedure proc_test1 is
begin
  dbms_output.put_line('helloworld'); 
end;
/

4、查看用户名的ID

SQL> select username,user_id from dba_users where username='BYS';

USERNAME                          USER_ID
------------------------------ ----------
RAY                                    90

5、利用闪回查询查看被误操作的存储过程对象的ID

SELECT obj# FROM obj$ 
AS OF TIMESTAMP TO_TIMESTAMP('2018-03-22 18:42:00', 'YYYY-MM-DD HH24:MI:SS')
WHERE NAME = 'PROC_TEST1' and owner#=90;

6、根据OBJECT_ID进行闪回查询

SELECT source FROM source$ 
AS OF TIMESTAMP TO_TIMESTAMP('2018-03-22 18:42:00', 'YYYY-MM-DD HH24:MI:SS') 
where obj# = 620576;

SOURCE
--------------------------------------------------------------------------------
procedure proc_test1 is
begin
  dbms_output.put_line('hello');
end;

你可能感兴趣的:(Oracle日常运维)