Oracle SQL statement tracking

Source: Internet
Author: User

Oracle SQL statement tracking

1. SQL statement tracking

The execution of SQL statements must be performed on the Oracle server. The Oracle server detects and records all SQL statements executed by the access process. The commands used below are all executed in command line mode. Therefore, we need to use command line to log on to the Oracle database as an administrator. The following describes how to use the tool.

First, we need to catch up with the SQL statement. We need to determine the session ID of the tracing client process. The following commands enumerate all the access process session IDs and serial ports on the current server, then select the session ID and serial port to be detected.

Select username, sid, serial # from v $ session where username is not null;

Then, you can trace the selected session ID and serial port SQL statements, as shown in the following command.

EXECUTE sys. dbms_system.set_ SQL _trace_in_session (10,264 2, TRUE );

After tracing SQL statements, we can perform operations on the client, and the SQL statements used in these operations will be recorded until we end SQL statement tracing.

After the client completes the operation, use the following command to end SQL statement tracing.

EXECUTE sys. dbms_system.set_ SQL _trace_in_session (10,264 2, FALSE );

After the synchronization ends, an latest file is generated in the Oracle server folder. for files with the trc suffix, we can use the Search Everything tool to find the most recently produced files. trc file, and then use the tkprof tool to parse the file.

2 TRC File Parsing

Parses the generated. in the trc file, you must use the tkprof tool. This tool has a lot of complex parameters for use. If you do not have complex requirements, you can use the following simple command. the trc file is output as a text file.

The parsing command is as follows:

Tkprof sqlplus_007.trc out.txt

Sqlplus_007.trc is the data Tracing file

Out.txt format the output file

Open the out.txt file to view the SQL statement execution status.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.