Tkprof read Oracle trace

Source: Internet
Author: User

SQL trace is mainly used to monitor the SQL of databases and monitor and adjust the applications acting on data at any time.Program. For example, the ERP system has many application interfaces and involves many underlying operations. If you want to know which SQL statements are executed in the underlying database for operations on a specific interface, you need to enable the trace function to record these SQL operations, so that developers can understand what upper-layer applications have done to the database. This article uses a simple example to demonstrate how to use tkprof to read the Oracle trace file.

1. Enable the trace function

Some applications can enable trace. For example, Oracle ERP has the trace function in the menu bar of the application interface, for example:

The same settings are also available in the PL/SQL menu:

Of course, you can also execute the following command in sqlplus to enable trace:

 
Alter session setSQL _trace=True;/* Enable */Alter session setSQL _trace=False;/* Close */
2. Record SQL to trace files

Use sqlplus to log on to the database, enable the trace function, execute an SQL statement, and disable trace:

3. Browse trace files

Open the trace file directory:

CD/ora10g/admin/otdrdb/udump

By date, the file that appears at the top is the generated trace file:

Ls-T | more

Let's take a look at the unprocessed trace file. The content format is not easy to read:

More otdrdb_ora_30597.trc

Use tkprof to handle otdrdb_ora_30597.trc:

Tkprof otdrdb_ora_30597.trc

Enter the outputfile name, for example, otdrdb_ora_30597.txt

The content of the otdrdb_ora_30597.txt file is as follows:

The previously executed select count (*) from users statement will be reflected in the trace file, and some corresponding execution parameters will also be reflected. In this way, you can monitor the database operations of applications at any time.

For more information about tkprof, see http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96533/sqltrace.htm#1018.

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.