我无法使用Autotrace Traceonly Oracle打印统计信息

时间:2017-04-29 11:06:58

标签: sql oracle oracle11g oracle-sqldeveloper

我想打印sql查询的执行统计信息。为此,我想使用autotrace。当我在解释时使用autotrace时,我没有问题,它正确打印所有内容。但是,当我想使用autotrace traceonly时,程序会说“不支持”。我的用户拥有所有权限......那么问题是什么?

set autotrace traceonly;
set timing on;

-- Here i have my 4 Querys

set timing off;

结果:

  

目前不支持Traceonly选项。

我也想打印这样的东西:

Image

打印组合的命令是什么,就像在我的图像中一样?

有什么想法吗?

我正在使用SQL Developer和Oracle 11-G

1 个答案:

答案 0 :(得分:2)

您需要使用SQL * Plus。

[oracle@vbgeneric ~]$ sqlplus demo/oracle

SQL*Plus: Release 12.1.0.2.0 Production on Sat Apr 29 16:31:12 2017

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Last Successful login time: Sat Apr 29 2017 09:03:35 -04:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> set autotrace traceonly;
set timing on;

select 1 from dual;
select 2 from dual;
select 3 from dual;
select 4 from dual;

set timing off;SQL> SQL> SQL> 
Elapsed: 00:00:00.02

Execution Plan
----------------------------------------------------------
Plan hash value: 1388734953

-----------------------------------------------------------------
| Id  | Operation    | Name | Rows  | Cost (%CPU)| Time|
-----------------------------------------------------------------
|   0 | SELECT STATEMENT |  |     1 |     2   (0)| 00:00:01 |
|   1 |  FAST DUAL   |  |     1 |     2   (0)| 00:00:01 |
-----------------------------------------------------------------


Statistics
----------------------------------------------------------
      0  recursive calls
      0  db block gets
      0  consistent gets
      0  physical reads
      0  redo size
    535  bytes sent via SQL*Net to client
    552  bytes received via SQL*Net from client
      2  SQL*Net roundtrips to/from client
      0  sorts (memory)
      0  sorts (disk)
      1  rows processed

SQL> 
Elapsed: 00:00:00.01

Execution Plan
----------------------------------------------------------
Plan hash value: 1388734953

-----------------------------------------------------------------
| Id  | Operation    | Name | Rows  | Cost (%CPU)| Time|
-----------------------------------------------------------------
|   0 | SELECT STATEMENT |  |     1 |     2   (0)| 00:00:01 |
|   1 |  FAST DUAL   |  |     1 |     2   (0)| 00:00:01 |
-----------------------------------------------------------------


Statistics
----------------------------------------------------------
      0  recursive calls
      0  db block gets
      0  consistent gets
      0  physical reads
      0  redo size
    535  bytes sent via SQL*Net to client
    552  bytes received via SQL*Net from client
      2  SQL*Net roundtrips to/from client
      0  sorts (memory)
      0  sorts (disk)
      1  rows processed

SQL> 
Elapsed: 00:00:00.01

Execution Plan
----------------------------------------------------------
Plan hash value: 1388734953

-----------------------------------------------------------------
| Id  | Operation    | Name | Rows  | Cost (%CPU)| Time|
-----------------------------------------------------------------
|   0 | SELECT STATEMENT |  |     1 |     2   (0)| 00:00:01 |
|   1 |  FAST DUAL   |  |     1 |     2   (0)| 00:00:01 |
-----------------------------------------------------------------


Statistics
----------------------------------------------------------
      0  recursive calls
      0  db block gets
      0  consistent gets
      0  physical reads
      0  redo size
    535  bytes sent via SQL*Net to client
    552  bytes received via SQL*Net from client
      2  SQL*Net roundtrips to/from client
      0  sorts (memory)
      0  sorts (disk)
      1  rows processed

SQL> 
Elapsed: 00:00:00.00

Execution Plan
----------------------------------------------------------
Plan hash value: 1388734953

-----------------------------------------------------------------
| Id  | Operation    | Name | Rows  | Cost (%CPU)| Time|
-----------------------------------------------------------------
|   0 | SELECT STATEMENT |  |     1 |     2   (0)| 00:00:01 |
|   1 |  FAST DUAL   |  |     1 |     2   (0)| 00:00:01 |
-----------------------------------------------------------------


Statistics
----------------------------------------------------------
      0  recursive calls
      0  db block gets
      0  consistent gets
      0  physical reads
      0  redo size
    535  bytes sent via SQL*Net to client
    552  bytes received via SQL*Net from client
      2  SQL*Net roundtrips to/from client
      0  sorts (memory)
      0  sorts (disk)
      1  rows processed

SQL> SQL>