美文网首页
Oracle 查询倒叙查询所有表更新时间

Oracle 查询倒叙查询所有表更新时间

作者: 发光驴子 | 来源:发表于2018-04-19 10:13 被阅读0次

    先测试独立一张表的更新时间sql 可用不可用

    select max(ora_rowscn), to_char( scn_to_timestamp(nvl(max(ora_rowscn),1002267)),'yyyy-mm-dd hh24:mi:ss') from DM00_HSBM8 t;
    
    select max(ora_rowscn), to_char( scn_to_timestamp(nvl(max(ora_rowscn),1002267)),'yyyy-mm-dd hh24:mi:ss') from 表名 t;
    

    测试成功后,执行如下语句,得到Oracle所有表的 更新语句sql。

    select 'select ''' || t.TABLE_NAME  || ''' table_name, to_char(scn_to_timestamp(nvl(max(ora_rowscn),1002267)),''yyyy-mm-dd hh24:mi:ss'') updateTime from ' || t.TABLE_NAME || ' union all'  from user_tables t order by  t.TABLE_NAME;
    
    图片.png

    最后直接把所有语句粘出来,然后在外面来一层select

    select table_name, updateTime from 
    (select 'DM00_DPXZ' table_name, to_char(scn_to_timestamp(nvl(max(ora_rowscn),1002267)),'yyyy-mm-   dd hh24:mi:ss') updateTime from DM00_DPXZ union all
    select 'XSTJ_SA_SAWP' table_name, to_char(scn_to_timestamp(nvl(max(ora_rowscn),1002267)),'yyyy- mm-dd hh24:mi:ss') updateTime from XSTJ_SA_SAWP union all
    select 'XSTJ_SA_WP' table_name, to_char(scn_to_timestamp(nvl(max(ora_rowscn),1002267)),'yyyy-mm-dd hh24:mi:ss') updateTime from XSTJ_SA_WP)a order by updateTime desc
    

    相关文章

      网友评论

          本文标题:Oracle 查询倒叙查询所有表更新时间

          本文链接:https://www.haomeiwen.com/subject/ztgikftx.html