• sqlplus 分析执行计划


    转载 http://xm-koma.iteye.com/blog/1048451

    对于oracle9i,需要手工设置plustrace角色,步骤如下: 
    1、在SQL>connect sys/密码 as sysdba  (密码为:数据库所在的那台服务器的密码) 

    在sys用户下运行$ORACLE_HOME/sqlplus/admin/plustrce.sql 
    SQL>@$ORACLE_HOME/sqlplus/admin/plustrce.sql 

    这段sql的实际内容如下: 
    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 

    以上产生plustrace角色 

    2、在sys用户下把此角色赋予一般用户 
    SQL> grant PLUSTRACE to 用户名;   (用户名为:当前你登陆数据库的用户名,如:bbass) 
    3、然后在当前用户下运行$ORACLE_HOME/rdbms/admin/utlxplan.sql 
    SQL>@$ORACLE_HOME/rdbms/admin/utlxplan.sql  它会创建一个plan_table,用来存储分析SQL语句的结果。 
    4、SQL> set timing on 
    可查看SQL语句执行的用时 
    SQL> set autotrace on; 
    可查看SQL执行计划分析。 

      关于Autotrace几个常用选项的说明: 
      SET AUTOTRACE OFF ---------------- 不生成AUTOTRACE 报告,这是缺省模式 
      SET AUTOTRACE ON EXPLAIN ------ AUTOTRACE只显示优化器执行路径报告 
      SET AUTOTRACE ON STATISTICS -- 只显示执行统计信息 
      SET AUTOTRACE ON ----------------- 包含执行计划和统计信息 
        SET AUTOTRACE TRACEONLY ------ 同set autotrace on,但是不显示查询 

    5,关闭以上功能,在SQL/PLUS的窗口运行以下命令 

    set time off;                      (说明:关闭时间显示) 
    set autotrace off;

  • 相关阅读:
    JS的反射
    反射帮助类
    hdu 1097
    终于了解母函数了 ,感谢lz hdu 1248
    CommandArgument用法
    MOSS 2007 EventHandler 开发步骤
    《Microsoft Office SharePoint Server 2007案例实战开发》之对象介绍
    ASP.NET入门随想之检票
    DataTable,DataView和DataGrid中一些容易混淆的概念
    MOSS模型及其基本操作
  • 原文地址:https://www.cnblogs.com/cupsuccess/p/4244210.html
Copyright © 2020-2023  润新知