Tips: PL/SQL中监控执行进度两种方法
浏览:3492次 出处信息
这是我常用的两种PL/SQL监控运行状况的方法:
1. 使用dbms_application_info.SET_CLIENT_INFO
举例如下:
| 以下是代码片段: declare cursor cr is select rowid from test; delete_count number; total_count number; begin delete_count :=0; total_count :=0; for i in cr loop delete from test where rowid=i.rowid; delete_count :=delete_count+1; total_count :=total_count+1; if (delete_count>100) then dbms_application_info.SET_CLIENT_INFO(’ So far ‘||total_count||’ rows has been deleted’); delete_count :=0; commit; end if; end loop; end; / |
另开一session, select client_info from v$session where client_info like ‘So far%’;
注意info的长度有限制,超过64字符会被截断
2. 使用dbms_system.ksdwrt, 这个可以写到300个字符
KSDWRT Procedure
This procedure prints the message to the target file (alert log and/or trace file).
Syntax
DBMS_SYSTEM.KSDWRT (
dest IN BINARY_INTEGER,
tst IN VARCHAR2);
Parameters:
dest Destination is indicated by the following values:
1 - Write to trace file.
2 - Write to alertlog.
3 - Write to both.
tst Message (not tested for max length, but output with 300 chars was successful)
举例如下:
| 以下是代码片段: declare cursor cr is select rowid from test; delete_count number; total_count number; begin delete_count :=0; total_count :=0; for i in cr loop delete from test where rowid=i.rowid; delete_count :=delete_count+1; total_count :=total_count+1; if (delete_count>100) then dbms_system.ksdwrt (1,’ So far ‘||total_count||’ rows has been deleted’); delete_count :=0; commit; end if; end loop; end; / |
然后开一session, tail -30f xxx.trc
建议继续学习:
- Mysql监控指南 (阅读:20597)
- 批量添加主机到cacti+nagios的监控报警系统中 (阅读:14179)
- 我常用的主机监控shell脚本 (阅读:12511)
- 7 天打造前端性能监控系统 (阅读:10741)
- 如何监控HP服务器硬件状态 (阅读:10022)
- Cacti 添加 Nginx 监控 (阅读:9879)
- Linux下三种常用的流量监控软件对比 (阅读:9530)
- Cacti 添加 Memcached 监控 (阅读:8772)
- Cacti 添加 Apache 监控 (阅读:8502)
- 你应该知道的16个Linux服务器监控命令 (阅读:7800)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
扫一扫订阅我的微信号:IT技术博客大学习
<< 前一篇:尽量缩短oracle upgrade时间
后一篇:安装BBED >>
文章信息
- 作者:Eagle Fan 来源: eagle's home
- 标签: 监控
- 发布时间:2009-10-21 09:05:06
建议继续学习
近3天十大热文
-
[930] WordPress插件开发 -- 在插件使用 -
[130] 解决 nginx 反向代理网页首尾出现神秘字 -
[51] 如何保证一个程序在单台服务器上只有唯一实例( -
[51] 海量小文件存储 -
[50] 整理了一份招PHP高级工程师的面试题 -
[49] CloudSMS:免费匿名的云短信 -
[48] 全站换域名时利用nginx和javascri -
[48] 用 Jquery 模拟 select -
[47] Innodb分表太多或者表分区太多,会导致内 -
[46] ps 命令常见用法
