关于SQL_Trace

来源:互联网 发布:网络监控 距离 编辑:程序博客网 时间:2024/06/06 00:58

You work as a database administrator at Certkiller .com. In yourtest database, you find that a user's session is executing a lot ofS
QL statements, resulting in the generation of a large number oftrace
 files. While investigating the reason, you findthat SQL trace has b
een enabled at the instance level. You want to disable SQL trace,rem
otely, only for that user session to reduce the volume of tracedata
being generated. How do you achieve thisobjective? 
A. by setting the SQL_TRACE parameter to FALSE in the parameterfile 
B. by using DBMS_MONITOR.SESSION_TRACE_DISABLE to disable thetracing
 for the user session 
C. by setting the SQL_TRACE parameter to FALSE by using the ALTERSYS
TEM command in the user session 
D. by setting the SQL_TRACE parameter to FALSE by using the ALTERSES
SION command in the user session 
Answer: B


 模块级别跟踪:
SQL> execdbms_monitor.serv_mod_act_trace_enable(service_name=>
'EDGAR', module_name => 
用户级别跟踪:
SQL> execdbms_monitor.client_id_trace_enable(client_id =>'DEMO');

Client_id 就是数据库中的用户名。
会话级别跟踪:SQL> execdbms_monitor.session_trace_enable(138);138 就
是会话 ID. 
DBMS_MONITOR 是在 Oracle 10g 中引入的内置的程序包,通过该程序包可以
跟踪从客户机到中间层、再到后端数据库的任何用户的会话,从而可以较为容易
地标识创建大量工作量的特定用户。
SQL_TRACE 是 Oracle 提供的用于进行 SQL 跟踪的手段,是强有力的辅助诊断
工具.在日常的数据库问题诊断和解决中,SQL_TRACE 是非常常用的方法。
大多数时候我们使用 sql_trace 跟踪当前进程.通过跟踪当前进程可以发现当前
操作的后台数据库递归活动(这在研究数据库新特性时尤其有效),
研究 SQL 执行,发现后台错误等.
在 session 级启用和停止 sql_trace 方式如下:
启用当前 session 的跟踪:
SQL> alter session set sql_trace=true;
此时的 SQL 操作将被跟踪:
SQL> select count(*) from dba_users;
结束跟踪:
SQL> alter session set sql_trace=false;

0 0