db2監視器,監視數據庫執行語句 1)查看監視器選項 db2 get monitor switches; 2)修改語句跟蹤選項 www.2cto.com 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; www.2cto.com 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;