zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    流量调整和限流技术
    微软开源.NET Core的执行引擎CoreCLR{转载}
    Visual Studio 2015 前端开发工作流
    基于Redis的开源分布式服务Codis
    RemoteIE 开发者可跨平台使用IE测试网页
    参加MVP OpenDay 和2015 MVP Community Camp社区大课堂
    etcd:用于服务发现的键值存储系统
    Centos7下安装mono3.10.0
    在 Azure 上使用 Docker运行 Mono
    STOMP协议介绍
  • 原文地址:https://www.cnblogs.com/rusking/p/4029826.html
Copyright © 2011-2022 走看看