Sqlplus Analysis Execution Plan

Source: Internet
Author: User
Tags set time

Reprint http://xm-koma.iteye.com/blog/1048451

For oracle9i, you need to manually set the Plustrace role, as follows:
1, in Sql>connect sys/password as SYSDBA (password: the password of the server where the database resides)

Run $oracle_home/sqlplus/admin/plustrce.sql under SYS user
sql>@ $ORACLE _home/sqlplus/admin/plustrce.sql

The actual content of this SQL is as follows:
Set echo on
Drop role Plustrace;
Create role Plustrace;
Grant SELECT on V_$sesstat to Plustrace;
Grant SELECT on V_$statname to Plustrace;
Grant SELECT on V_$mystat to Plustrace;
Grant Plustrace to DBA with admin option;
Set echo off

The above produces the Plustrace role

2, under the SYS user to give this role to the general user
Sql> Grant Plustrace to user name; (User name: The user name of the current database you logged into, such as: Bbass)
3. Then run $oracle_home/rdbms/admin/utlxplan.sql under the current user
sql>@ $ORACLE _home/rdbms/admin/utlxplan.sql It creates a plan_table that stores the results of parsing SQL statements.
4. Sql> set Timing on
To see when SQL statement execution takes
Sql> set autotrace on;
To view SQL execution plan analysis.

Notes on several common options for autotrace:
SET AUTOTRACE OFF----------------does not generate a AUTOTRACE report, which is the default mode
SET AUTOTRACE on EXPLAIN------AUTOTRACE only show optimizer execution path report
SET AUTOTRACE on STATISTICS--Displays only execution statistics
SET AUTOTRACE on-----------------contains execution plans and statistics
Set AUTOTRACE traceonly------Same set AUTOTRACE on, but does not display query

5, turn off the above features, run the following command in the Sql/plus window

Set time off; (Description: Turn off time display)
Set Autotrace off;

Sqlplus Analysis Execution Plan

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.