Flashback Query(函数示例)

Flashback Query 函数,存储过程,包,触发器等对象
Flashback Drop 可以闪回与表相关联的对象, 如果是其他的对象,比如function,procedure,trigger等。 这时候,就需要使用到ALL_SOURCE 表来进行Flashback Query。
ALL_SOURCE describes the text source of the stored objects accessible to the current user.
Related Views
DBA_SOURCE describes the text source of all stored objects in the database.
USER_SOURCE describes the text source of the stored objects owned by the current user. This view does not display the OWNER column.
基于timestamp恢复的语句
SQL>SELECT text
FROM dba_source
AS OF TIMESTAMP TO_TIMESTAMP ('XXXXX', 'YYYY-MM-DD HH24:MI:SS')
WHERE owner = 'XXXX' AND name = '你删除的对象名'
ORDER BY line;
==========函数=================
未例:

SQL> CREATE OR REPLACE function getdate return date
2 as
3 v_date date;
4 begin
5 select sysdate into v_date from dual;
6 return v_date;
7 end;
8 /

函数已创建。

---------------查询函数---------------------------------------

SQL> ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS';

会话已更改。

SQL> select getdate() from dual;

GETDATE()
-------------------
2014-10-16 21:52:11

------------查询dba_source表-----------------------------------

SQL> select text from dba_source where name='GETDATE' order by line;

TEXT
--------------------------------------------------------------------------------
function getdate return date
as
v_date date;
begin
select sysdate into v_date from dual;
return v_date;
end;

已选择7行。

-----------------------------drop 函数,在查询,记录不存在----------------------

SQL> drop function getdate;

函数已删除。

SQL> select text from dba_source where name='GETDATE';

未选定行

--------------------使用flashback query 查询-------------------------------------

SQL> select text from dba_source as of timestamp to_timestamp('2014-10-16 21:52:11','yyyy-mm-dd hh24:mi:ss') where name='GETDATE' order by line;

TEXT
--------------------------------------------------------------------------------
function getdate return date
as
v_date date;
begin
select sysdate into v_date from dual;
return v_date;
end;

已选择7行。

重新执行该函数的代码即可恢复getdate函数

《FROM:http://blog.csdn.net/tianlesoftware/article/details/4677378

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值