oracle SET AUTOTRACE ON
2757 ワード
まずSYSで権限を設定します.
次に、実行計画が表示されます.
SET AUTOTRACE OFF----------AUTOTRACEレポートは生成されません.これがデフォルトモードです
SET AUTOTRACE ON EXPLAIN-----AUTOTRACEオプティマイザ実行経路レポートのみ表示
SET AUTOTRACE ON STATISTICS--実行統計のみ表示
SET AUTOTRACE ON----------実行計画と統計を含む
SET AUTOTRACE TRACEONLY------はset autotrace onと同じですが、クエリー出力は表示されません
注意:
PL SQLはSET AUTOTRACEをサポートしていないので、cannot set autotraceを報告します
C:\>sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on 3 19 22:00:45 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> @C:\oracle\product\10.2.0\db_1\sqlplus\admin\plustrce.sql
SQL>
SQL> drop role plustrace;
。
SQL> create role plustrace;
。
SQL>
SQL> grant select on v_$sesstat to plustrace;
。
SQL> grant select on v_$statname to plustrace;
。
SQL> grant select on v_$mystat to plustrace;
。
SQL> grant plustrace to dba with admin option;
。
SQL>
SQL> set echo off
SQL> grant plustrace to scott;
。
SQL>
次に、実行計画が表示されます.
SQL> conn scott/tiger
。
SQL> SELECT JOB, SUM(SAL) FROM EMP GROUP BY JOB;
JOB SUM(SAL)
--------- ----------
CLERK 4150
SALESMAN 5600
PRESIDENT 5000
MANAGER 8275
ANALYST 6000
SQL>
SQL> SET AUTOTRACE ON
SQL> SELECT JOB, SUM(SAL) FROM EMP GROUP BY JOB;
JOB SUM(SAL)
--------- ----------
CLERK 4150
SALESMAN 5600
PRESIDENT 5000
MANAGER 8275
ANALYST 6000
----------------------------------------------------------
Plan hash value: 4067220884
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 5 | 60 | 4 (25)| 00:00:01 |
| 1 | HASH GROUP BY | | 5 | 60 | 4 (25)| 00:00:01 |
| 2 | TABLE ACCESS FULL| EMP | 14 | 168 | 3 (0)| 00:00:01 |
---------------------------------------------------------------------------
----------------------------------------------------------
0 recursive calls
0 db block gets
7 consistent gets
0 physical reads
0 redo size
567 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
5 rows processed
SQL>
SET AUTOTRACE OFF----------AUTOTRACEレポートは生成されません.これがデフォルトモードです
SET AUTOTRACE ON EXPLAIN-----AUTOTRACEオプティマイザ実行経路レポートのみ表示
SET AUTOTRACE ON STATISTICS--実行統計のみ表示
SET AUTOTRACE ON----------実行計画と統計を含む
SET AUTOTRACE TRACEONLY------はset autotrace onと同じですが、クエリー出力は表示されません
注意:
PL SQLはSET AUTOTRACEをサポートしていないので、cannot set autotraceを報告します