If you want to view the dynamic SQL of DB2, use snapshot to view it. The following describes how to view the dynamic SQL of DB2. We hope this will help you learn about the dynamic SQL of DB2.
Use event monitor to view the execution of SQL statements in stored procedures.
Dig a hole first and add it later)
Supplement 1: event monitor)
Run event monitor
Unlike snapshot, event monitor has a significant impact on DB2 performance. This is caused by the amount of information written for each event object. Statement monitor has a great impact on performance, because the database engine must execute all the extra work for each query: not only can execute the query, the DB2 engine must also write all the features and runtime information of this query. This information must be written to a text file, which further reduces performance.
First, you must create an event monitor and run the monitor to collect the data to be analyzed. Rkmon is the name of the event monitor.
Open a new DB2 command line processor session and execute the following DB2 UDB command:
Db2 => connect to dbname
Db2 => update monitor switches using statement on
Db2 => create event monitor rkmon for statements write to file '/db2'
Db2 => set event monitor rkmon state = 1
Keep this session open until these database activities are completed. Make sure that the/db2 Directory has enough space to save the trace file. The/db2 Directory is selected here because all users can access this directory, but other directories can also be selected. Make sure that DB2 has access permissions for this directory ). The directory size depends on the number of SQL statements you want to capture. In the beginning, it is best to set it to 500 MB.
Execute normal database activities until the time period you want to monitor ends. This monitoring phase can be a problem generation period or a common database activity process. In the/db2 Directory, you should see a group of files with the extension ". evt.
Return to the session opened in step 1 and issue the following statement:
Db2 => set event monitor rkmon state = 0
Db2 => terminate
Run the following command at a normal Command Prompt:
$ Db2evmon-path/db2> sqltrace.txt
Delete rkmon
Drop event monitor rkmon
The preceding section describes how to view DB2 dynamic SQL statements.
Provides you with an in-depth understanding of the DB2 materialized query table.
Rollback of A DB2 partitioned Database
Implementation of DB2 partitioned Database Backup
DB2 logfilsiz parameter settings
Online Implementation of changing the DB2 page size