在Oracle9i中,使用External Table和动态SQL,在线地查看alter.log文件内容,从而进行某些查询、工作调度来监控错误。

使用下面的脚本可以实现上述的要求。

SQL> drop table e_alert_log;

Table dropped.

SQL> drop table t_perm_alert_log;

Table dropped.

SQL> drop table t_temp_alert_log;

Table dropped.

SQL> create or replace DIRECTORY alert_dir as 'D:oracleadminoracle9bdump';

Directory created.

SQL> create table e_alert_log

2 (detail_line VARCHAR2(2000)

3 ) ORGANIZATION EXTERNAL

4 (TYPE oracle_loader

5 DEFAULT DIRECTORY alert_dir

6 ACCESS PARAMETERS

7 ( RECORDS DELIMITED BY NEWLINE

8 nobadfile

9 nologfile

10 nodiscardfile

11 FIELDS TERMINATED by ' '

12 MISSING FIELD VALUES ARE NULL

13 (detail_line )

14 )

15 LOCATION('alert_oracle9.log') )

16 parallel 5

17 REJECT LIMIT UNLIMITED;

Table created.

SQL> create table t_perm_alert_log

2 (row_id number,

3 detail_line varchar2(2000) )

4 tablespace users

5 storage (initial 1m next 1m pctincrease 0);

Table created.

SQL>

SQL> create table t_temp_alert_log

2 (row_id number,

3 detail_line varchar2(2000) )

4 tablespace users

5 storage (initial 1m next 1m pctincrease 0);

Table created.

SQL>

SQL>

SQL> create or replace procedure update_alert as

2 BEGIN

3

4 -- This truncates the temp table from the last run...

5 execute immediate 'truncate table t_temp_alert_log';

6

7 -- Now, populate the temp table with all the alert log contents....

8 execute immediate 'insert into t_temp_alert_log select rownum,

9 detail_line from e_alert_log';

10

11 -- Now, populate the perm table with just the changes.....

12 execute immediate 'insert into t_perm_alert_log select row_id,

13 detail_line from t_temp_alert_log b

14 where b.row_id > (select nvl(max(a.row_id),0) from t_perm_alert_log a)';

15 END;

16 /

Procedure created.

SQL> exec update_alert

PL/SQL procedure successfully completed.

SQL> commit;

Commit complete.

SQL> select DETAIL_LINE from t_temp_alert_log sample(0.1) ;

DETAIL_LINE

--------------------------------------------------------------------------------

ORA-12012: error on auto execute of job 1

Created Undo Segment _SYSSMU18$

Undo Segment 8 Offlined

3 rows selected.

oracle alter_log,在线查看alter.log文件内容相关推荐

  1. Linux/Unix shell 监控Oracle告警日志(monitor alter log file)

    使用shell脚本实现对Oracle数据库的监控与管理将大大简化DBA的工作负担,如常见的对实例的监控,监听的监控,告警日志的监控,以及数据库的备份,AWR report的自动邮件等.本文给出Linu ...

  2. tail查看nohup.out文件内容

    1.前台实时查看nohub.out文件内容: tail -f nohup.out 2.根据关键字查看 tail -f nohup.out |grep "关键字" 3.输出文件最后1 ...

  3. git如何查看缓存区文件内容_GIT实操手册 —— 值得收藏的GIT常用命令字典

    目录git config 配置 git help 显示有关Git的帮助信息 git init 初始化 git add 将文件内容添加到暂存区 git clone 将存储库克隆到新目录中 git sta ...

  4. linux下不解包查看tar包文件内容

    为减少日志文件占用的空间,很多情况下我们会将日志文件以天或周为周期打包成tar.gz 包保存.虽然这样做有利空间充分利用,但当我们想查看压缩包内的内容时确很不方便.如果只是一个tar.gz文件,可以将 ...

  5. linux如何查看tar的文件,linux下不解包查看tar包文件内容

    为减少日志文件占用的空间,很多情况下我们会将日志文件以天或周为周期打包成tar.gz 包保存.虽然这样做有利空间充分利用,但当我们想查看压缩包内的内容时确很不方便.如果只是一个tar.gz文件,可以将 ...

  6. git如何查看缓存区文件内容_详解Git工作区、暂存区、历史记录区以及git reset、git revert、git checkout等撤销命令的区别...

    一.可以将git简单的分为三个区域   1.工作区(working directory)    2.暂缓区(stage index)    3.历史记录区(history)    如图: 其中git ...

  7. linux查看程序写文件内容,Linux 文件内容查看命令

    Linux系统中使用以下命令来查看文件的内容: cat  由第一行开始显示文件内容 tac  从最后一行开始显示,可以看出 tac 是 cat 的倒著写! nl   显示的时候,顺道输出行号! mor ...

  8. apk解压后查看 AndroidManifest.xml 文件内容,解决乱码问题

    解决方案一. 一般对于我来说如果需要知道一个apk的包名的话,有两种比较快速的方式: (1)使用命令:aapt dump badging xxx.apk ,一般是apk就在电脑上,使用比较方便. (2 ...

  9. java 实现在线编辑本地pdf文件内容

    功能描述:将pdf文件上传到服务器,然后服务器读取上传的pdf文件内容,然后渲染到在线富文本中,再然后在富文本中修改完毕点击保存,再将上传的pdf文件内容修改为在线富文本中的内容 1.实现将PDF文件 ...

最新文章

  1. STM32的:外部中断线EXTIN和外部中断向量EXTIN_IRQn和中断服务程序入口EXTIN_IRQHandler详解
  2. XAMPP的安装与使用
  3. 使用BaaS更快地构建Xamarin应用程序
  4. IBM Machine Learning学习笔记(二)——Supervised Learning: Regression
  5. android消息,android消息机制
  6. UVa 10118 免费糖果(记忆化搜索+哈希)
  7. 芯片数据手册下载和阅读
  8. java excel 取消科学计数法_java使用poi解析或处理excel的时候,如何防止数字变成科学计数法的形式...
  9. 这样演示正弦和余弦的相互变换,不怕难懂!
  10. 实用性室内地图导航软件
  11. 方面和服务,差别大吗?
  12. OK6410A 之 SPI 驱动 测试 步骤
  13. 自学Java软件编程需要哪些基础?
  14. BestMPRBaseVtk-003-修改工程,搬运官方代码并尝试理解-2
  15. veket linux应用软件,Veket下载_Veket Linux(开源Linux操作系统)V5.192D完整版
  16. 一张纸的厚度大约是0.08mm,对折多少次之后能达到珠穆朗玛峰的高度(8848.13米)?...
  17. 转发与重定向的区别详解
  18. cadence的parametric analysis设置
  19. Django 开发MVT-模型
  20. 企业微信自建应用(JS-SDK):聊天工具栏分享消息到会话

热门文章

  1. c语言枚举入门,C语言入门之枚举与位运算(1)
  2. 山师计算机试题答案,山师计算机应用技术试题及答案
  3. android c 对象为空,ndk-jni中C/C++接口函数修改函数参数jobject对象成员值(数组)的有关问题...
  4. 多思计组原理虚拟实验室_先睹为快!汽院实验室组团来亮相_搜狐汽车
  5. 版本不一致_一致哈希:Beyond the basics
  6. 浅谈面向对象开发原则:高内聚,低耦合
  7. WPF中使用WindowChrome自定义窗口中遇到的最大化问题
  8. XVIII Open Cup named after E.V. Pankratiev. GP of Urals
  9. Django开发基础----操作数据库
  10. Bootloader之uBoot简介(转)