(1)cd [ORACLE_HOME]/rdbms/admin
- x' v0 h p9 L5 M, M$ y& c0 f (2)作为SYS 登录SQL*Plus;
* W J+ M! g* Y' `$ n2 N, O (3)运行@utlxplan.sql; . l1 g% w" j8 s) o2 T
(4)运行CREATE PUBLIC SYNONYM PLAN_TABLE FOR PLAN_TABLE;
8 C& [# _$ A X& u M (5)运行GRANT ALL ON PLAN_TABLE TO PUBLIC。 6 Q \4 {. M3 ]" X( E
重申一遍,如果愿意,可以把GRANT 命令中PUBLIC 替换为每个用户。
# m$ k7 Y4 \( W. L 附实例: 7 {0 B* b$ x8 q( u' d; u/ y! a
想在scott下使用autotrace
# R1 G- v, F/ I# g. q/ C SQL> set autotrace on; 0 S8 m# j9 k* H3 P: A
SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled % B0 P: m; d. o- }
SP2-0611: Error enabling STATISTICS report 5 _7 ^$ l) j" D: f$ g' V; l
SQL> @/u01/app/oracle/product/10.2.0/db_1/sqlplus/admin/plustrce.sql
( g p! `+ c( [7 x SQL>
; z z; h0 R# `1 m7 O SQL> drop role plustrace;
& }+ e: U R. \( j: z& n Role dropped.
7 e& ^% L0 ]5 W4 E SQL> create role plustrace;
' t9 i) X- J4 H. r( v2 u4 g Role created. $ C; {$ S% y* _) d
SQL>
$ `; \1 ?+ }# W! A" f9 Y( s: l' g SQL> grant select on v_$sesstat to plustrace; - [% R, f. } ?1 }( s* }# i& j: X
Grant succeeded.
5 i3 }" w( Z: m" K ]4 `3 d SQL> grant select on v_$statname to plustrace;
9 [8 f% ]! z, n& D- B Grant succeeded.
# _# t7 V+ o) ^0 B9 [ SQL> grant select on v_$mystat to plustrace; / q( m8 N$ G1 I7 w
Grant succeeded.
& z7 W! ?8 Z! ` R3 `; z SQL> grant plustrace to dba with admin option;
, ^4 F* k" R$ j3 g Grant succeeded. : r X/ b- x" f
SQL> 0 c- O3 y t7 x; e
SQL> set echo off / r7 |% V0 [( ` k- k6 S
SQL> / q0 R- B/ j' E+ @0 q' K
SQL>
7 M" R b4 N; O2 M. J, k9 H SQL>
7 ]* c# p, z1 B; U+ | SQL> grant plustrace to scott;
9 f& Z9 v8 U8 O& _4 r Grant succeeded.
' B$ O! h2 I, \/ r8 b7 G 再次设置
( c4 a/ G+ z, Z [oracle@oracle admin]$ sqlplus scott/tiger : q. t9 I4 Y! I) q: Q
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Sep 24 14:22:40 2008
# m8 I% y" ]; q/ L0 v Copyright (c) 1982, 2005, Oracle. All rights reserved.
5 @' z5 B5 ?+ o3 k$ |. }% P9 K Connected to:
) @ X( Q+ c: U3 y4 q5 h Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production ' |7 K2 [( Z! ^
With the Partitioning, OLAP and Data Mining options ! j: a' H. V2 l2 ]" x" z
SQL> set autotrace on; , Z0 f4 l4 ~+ {* N- r
SQL> set autotrace traceonly; 5 T: u& a$ X% Z3 S, M6 U* }
SQL> set timing on; |