1 SQL statement tracking
Tracking the implementation of SQL statements need to be carried out in the Oracle server-side, Oracle server-side will detect and record the implementation of the process of access to all SQL statements. The following command is used in the command line mode, so we need to use the command line as an administrator login Oracle database. The following is a detailed procedure for using the tool.
First of all, to catch up with the SQL statement, we need to determine the process of tracking the client session ID, the following command enumerates all the current server session ID and serial access to all processes, and then select the need to detect the session ID and serial port.
Select username, sid, serial # from v $ session where username is not null;
And then for the selected session ID and serial port for SQL statement tracking, as shown in the following command.
EXECUTE sys.dbms_system.set_sql_trace_in_session (10, 2642, TRUE);
Start tracking SQL statement, we can operate on the client, and these operations using the SQL statement will be recorded, until we end the SQL statement to track.
After the final client operation is complete, use the following command to end the SQL statement tracking.
EXECUTE sys.dbms_system.set_sql_trace_in_session (10, 2642, FALSE);
After the chase in the end of the Oracle server will produce a folder under the latest. Trc suffix file, we can use Search Everything tool to find the most recent production. Trc file, and then use the tkprof tool to resolve the file.
2 TRC file resolution
To parse the generated .trc file, you need to use the tkprof tool, which has a lot of complex parameters available. If you do not do complex requirements, you can use the following simple command to output the .trc file as a text file.
Parsing commands are as follows:
Tkprof sqlplus_007.trc out.txt
Sqlplus_007.trc is the data trace file
Out.txt format for the output file
Open out.txt file, you can access the SQL statement execution.