1)查看监视器选项
db2 get monitor switches;
2)修改语句跟踪选项
db2 update monitor switches using statement on;
3)创建语句监视器
windows:
db2 connect to dbname user db2admin using db2admin ;
db2 create event monitor state_event for statements write to file 'c:\state_event\';
linux:
db2 connect to dbname user db2inst4 using db2inst4;
db2 create event monitor state_event for statements write to file '/home/db2inst4/state_event/';
4)激活监视器
mkdir c:\state_event
db2 set event monitor state_event state=1;
5)运行应用程序 例如查询:select * from table_name;
6)完成输出
db2 flush event monitor state_event buffer;
7)关闭监视器
db2 set event monitor state_event state=0;
db2 update monitor switches using statement off;
drop event monitor state_event;
8)格式化结果
db2evmon -path c:\state_event> c:\sql.txt;
db2evmon -path /home/db2inst4/state_event > /home/db2inst4/sql.txt;
9)删除监视器
db2 drop event monitor state_event;
db2 get monitor switches;
2)修改语句跟踪选项
db2 update monitor switches using statement on;
3)创建语句监视器
windows:
db2 connect to dbname user db2admin using db2admin ;
db2 create event monitor state_event for statements write to file 'c:\state_event\';
linux:
db2 connect to dbname user db2inst4 using db2inst4;
db2 create event monitor state_event for statements write to file '/home/db2inst4/state_event/';
4)激活监视器
mkdir c:\state_event
db2 set event monitor state_event state=1;
5)运行应用程序 例如查询:select * from table_name;
6)完成输出
db2 flush event monitor state_event buffer;
7)关闭监视器
db2 set event monitor state_event state=0;
db2 update monitor switches using statement off;
drop event monitor state_event;
8)格式化结果
db2evmon -path c:\state_event> c:\sql.txt;
db2evmon -path /home/db2inst4/state_event > /home/db2inst4/sql.txt;
9)删除监视器
db2 drop event monitor state_event;