zoukankan      html  css  js  c++  java
  • sqlplus的autotrace开关

    官方文档https://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_eight.htm#i1037226

    image

    set autotrace off表示关闭,是默认的(set autot off)

    set autotrace on表示显示结果、执行计划、统计信息(set autot on)

    set autotrace on explain表示显示结果、执行计划(set autot on exp)

    set autotrace on statistics表示显示结果、统计信息(set autot on stat)

    set autotrace traceonly表示显示执行计划、统计信息(set autuot trace)

    set autotrace traceonly explain表示显示执行计划(set autot trace exp)

    set autotrace traceonly statistics表示显示统计信息(set autot trace stat)


    统计信息可以看到资源消耗量,如物理读、逻辑读、redo量、排序量等


    autotrace简写为autot

    explain简写为exp

    statistics简写为stat

    traceonly简写为trace


    用户要有创建PLAN_TABLE表和有PLUSTRACE角色,才行

    比如给scott用户赋权限,用scott用户执行@$ORACLE_HOME/rdbms/admin/utlxplan.sql 来创建PLAN_TABLE表

    然后用sys用户执行@$ORACLE_HOME/sqlplus/admin/plustrce.sql 来创建PLUSTRACE角色

    然后GRANT PLUSTRACE TO scott即可

    具体如下:

    16:27:36 SCOTT@edw> set autotrace on
    SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled
    SP2-0611: Error enabling STATISTICS report
    16:27:51 SCOTT@edw> @$ORACLE_HOME/rdbms/admin/utlxplan.sql   
    
    Table created.
    
    Elapsed: 00:00:00.11
    16:59:54 SCOTT@edw> conn / as sysdba;
    Connected.
    17:00:22 SYS@edw> @$ORACLE_HOME/sqlplus/admin/plustrce.sql
    17:00:32 SYS@edw> 
    17:00:32 SYS@edw> drop role plustrace;
    drop role plustrace
              *
    ERROR at line 1:
    ORA-01919: role 'PLUSTRACE' does not exist
    
    
    Elapsed: 00:00:00.01
    17:00:32 SYS@edw> create role plustrace;
    
    Role created.
    
    Elapsed: 00:00:00.01
    17:00:32 SYS@edw> 
    17:00:32 SYS@edw> grant select on v_$sesstat to plustrace;
    
    Grant succeeded.
    
    Elapsed: 00:00:00.01
    17:00:32 SYS@edw> grant select on v_$statname to plustrace;
    
    Grant succeeded.
    
    Elapsed: 00:00:00.01
    17:00:32 SYS@edw> grant select on v_$mystat to plustrace;
    
    Grant succeeded.
    
    Elapsed: 00:00:00.00
    17:00:32 SYS@edw> grant plustrace to dba with admin option;
    
    Grant succeeded.
    
    Elapsed: 00:00:00.01
    17:00:32 SYS@edw> 
    17:00:32 SYS@edw> set echo off
    
    Elapsed: 00:00:00.01
    17:01:27 SYS@edw> GRANT PLUSTRACE TO scott;    
    
    Grant succeeded.
    
    Elapsed: 00:00:00.00
    17:01:47 SYS@edw> 
    
  • 相关阅读:
    js使用html2canvas实现页面截图并保存图片
    微信小程序之图片base64解码
    微信小程序之回调函数
    小程序横向滚动
    搭建vue开发环境的步骤
    检测算法简介及其原理——fast R-CNN,faster R-CNN,YOLO,SSD,YOLOv2,YOLOv3
    hadoop常用命令
    工作流调度系统Azkaban的简介和使用
    java微服务简介与实战
    mxnet快速入门教程
  • 原文地址:https://www.cnblogs.com/yongestcat/p/13392208.html
Copyright © 2011-2022 走看看