Tuesday, November 23, 2010

Autotrace , plustrace role

Using AUTOTRACE in SQL*Plus

Steps
 Creating the PLUSTRACE ROLE
 Granting the PLUSTRACE ROLE to the user
 Using autotrace


1. Creating the PLUSTRACE ROLE
sys@DEMO> @$ORACLE_HOME/sqlplus/admin/plustrce.sql
sys@DEMO>
sys@DEMO> drop role plustrace;
drop role plustrace
          *
ERROR at line 1:
ORA-01919: role 'PLUSTRACE' does not exist

sys@DEMO> create role plustrace;
Role created.

sys@DEMO> grant select on v_$sesstat to plustrace;
Grant succeeded.

sys@DEMO> grant select on v_$statname to plustrace;
Grant succeeded.

sys@DEMO> grant select on v_$mystat to plustrace;
Grant succeeded.

sys@DEMO> grant plustrace to dba with admin option;
Grant succeeded.
sys@DEMO> set echo off

2. Granting the PLUSTRACE ROLE to the user

CONNECT / AS SYSDBA
GRANT PLUSTRACE TO HR;
Grant succeeded.

3. Using autotrace

sqlplus hr/hr
Ø       set autotrace
Ø       Usage: SET AUTOT[RACE] {OFF | ON | TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]]
Hope this helps. Regards Rupam