服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > 数据库技术 > Oracle技术 > Oracle开发 > 查看文档

初学者必读:sqlplus的autotrace的设置

【赛迪网-it技术报道】autotrace是sql*plus中的一个工具,可以显示所执行查询的解释计划(explain plan)以及所用的资源。

(如果是其它版本的话可能要先执行/rdbms/admin/utlxplan.sql;再create public synonym plan_table for plan_table;)

grant all on plan_table to public;

运行sqlplus/admin/plustrace.sql;内容如下:

--

-- copyright (c) oracle corporation 1995, 2002. all rights reserved.

--

-- name

-- plustrce.sql

--

-- description

-- creates a role with access to dynamic performance tables

-- for the sql*plus set autotrace ... statistics command.

-- after this script has been run, each user requiring access to

-- the autotrace feature should be granted the plustrace role by

-- the dba.

--

-- usage

-- sqlplus "/ as sysdba" @plustrce

--

-- catalog.sql must have been run before this file is run.

-- this file must be run while connected to a dba schema.

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

再执行:

grant plustrace to public;

set autotrace off;

set autotrace on explain;

set autotrace on statistics;

set autotrace on;

扫描关注微信公众号