zoukankan      html  css  js  c++  java
  • oracle 外部表查alter日志

    --创建文件夹,路径是alter日志的路径
    create or replace directory data_dir as
    '/u01/app/oracle/diag/rdbms/orcl/orcl/trace';
    
    --创建外部表
    create table alert_log(
           text_line varchar2(225)
    )
    organization external
    (
           TYPE ORACLE_LOADER
           DEFAULT DIRECTORY DATA_DIR
           ACCESS PARAMETERS
           (
                  RECORDS DELIMITED BY NEWLINE
                  FIELDS
           )
           LOCATION
           (
                  'alert_orcl.log'
           )
    );
    
    --查询数据库启动时间sql
    select to_char(LAST_TIME) shutdown,
           to_char(start_time) starup,
           round((start_time - LAST_TIME) * 24 * 60, 2) mins_down,
           round((LAST_TIME - lag(start_time) over(order by r)), 2) days_up,
           case
             when (lead(r) over(order by r) is null) then
              round((sysdate - start_time), 2)
           end days_still_up
      from (select r,
                   to_date(last_time,
                           'Dy Mon DD HH24:MI:SS YYYY',
                           'NLS_DATE_LANGUAGE = American') LAST_TIME,
                   to_date(start_time,
                           'Dy Mon DD HH24:MI:SS YYYY',
                           'NLS_DATE_LANGUAGE = American') start_time
              from (select r,
                           text_line,
                           lag(text_line, 1) over(order by r) start_time,
                           lag(text_line, 2) over(order by r) last_time
                      from (select rownum r, text_line
                              from alert_log
                             where text_line like '___ ___ __ __:__:__ 20__'
                                or text_line like 'Starting ORACLE instance %'))
             where text_line like 'Starting ORACLE instance %');
  • 相关阅读:
    自定义样式滚动条
    html文本超出加省略号
    getcomputedstyle和style的区别
    模块化设计
    js数组取出非重复元素
    vue 获取元素高度
    js 滚动条滑动
    swiper基本使用
    flex弹性盒子布局
    js 地区三级联动 2
  • 原文地址:https://www.cnblogs.com/wolil/p/6641032.html
Copyright © 2011-2022 走看看