Oracle Sqlplus AUTOTRACE settings

AUTOTRACE is a tool of SQLPlus that can display the explain plan of the executed query and the resources used.

1. Configure AUTOTRACE

1. Enter the $ORACLE_HOME/rdbms/admin directory

Among them, $ORACLE_HOME is your Oracle installation directory, which should have been configured in the environment variables during the installation process.

2. Log in to SQLPlus as the SYS user or a user with the SYSDBA role.

[oracle@oradb ~]cd /u01/app/oracle/product/11.2.0/db_1/rdbms/admin/
[oracle@oradb admin]$ sqlplus / as sysdba

3. Execute @plustrce script

SYS@orcl> @plustrce;

 4. Execute authorized commands

SYS@orcl> GRANT PLUSTRACE TO PUBLIC;

 You can also replace PUBLIC in the GRANT command with a specific user.

 Second,Restraint report

When AUTOTRACE is started, SQLPlus will automatically generate a report every time a SQL statement is successfully executed. This report will display the execution path of the SQL statement (generated by the SQL optimizer) and some statistical information during the statement execution. This information will assist in monitoring and tuning SQL statements.

Reporting options for AUTOTRACE:

· SET AUTOTRACE OFF: Do not generate AUTOTRACE reports, this is the default setting.
· SET AUTOTRACE ON EXPLAIN: The AUTOTRACE report only displays the optimizer execution path.
· SET AUTOTRACE ON STATISTICS: The AUTOTRACE report only displays execution statistics of SQL statements.
· SET AUTOTRACE ON: The AUTOTRACE report includes both the optimizer execution path and the execution statistics of the SQL statement.
· SET AUTOTRACE TRACEONLY: This is similar to SET AUTOTRACE ON, but does not display the user's query output (if any).

· SET AUTOTRACE TRACEONLY EXPLAIN: This is similar to SET AUTOTRACE ON, but does not display the user's query output (if any), nor does it display execution statistics of the SQL statement.

AUTOTRACE command reference details list:

various combinations abbreviation SQL execution results Implementation plan LF
SET AUTOTRACE ON those cars are AND AND AND
SET AUTOTRACE OFF (default) set cars off AND N N
SET AUTOTRACE TRACEONLY set cars trace N AND AND
SET AUTOTRACE TRACEONLY EXPLAIN set autot trace exp N AND N
SET AUTOTRACE TRACEONLY STATISTIC autot trace state set N AND N

3. Configure Statspack

A user with the SYSDBA authority role must connect to Oracle to install Statspack.

Run script after login

@spcreate.sql

During the execution of the script, some information will be entered

1. What password should be used for the PERFSTAT Schema to be created;

2. The default table space to be used by PERFSTAT;

3. The default temporary table space to be used by PERFSTAT;

Screenshot of the creation process

 The following screenshot appears, indicating that the creation has been completed.

 If you make a mistake in the input or accidentally cancel the installation, run a script to delete the created users and installed views before reinstalling next time.

$ORACLE_HOME/rdbms/admin/spdrop.sql

END.

Guess you like

Origin blog.csdn.net/GYN_enyaer/article/details/123706733