易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL语句优化实践之一SQL_TRACE

SQL语句优化实践之一SQL_TRACE
 
环境:在PL/sql上调试数据
Pl/sql developer工具连接实例后即作为一个用户进程占用一个session;
 
select * from  v$session t  where t.PROGRAM='plsqldev.exe' and  t.USERNAME='DZJC'
查询结果显示了几个关键的字段
SADDR   RAW(4)  Session address 内存地址
SID  NUMBER  Session identifier  唯一标识
SERIAL#  NUMBER 
Session serial number. Used to identify uniquely a session's objects. Guarantees that session-level commands are applied to the correct session objects if the session ends and another session begins with the same session ID 
STATUS  VARCHAR2(8) 
Status of the session: ACTIVE (currently executing SQL), INACTIVE, KILLED (marked to be killed), CACHED (temporarily cached for use by Oracle*XA), SNIPED (session inactive, waiting on the client) 当期状态
MACHINE  VARCHAR2(64)  Operating system machine name 
PROGRAM  VARCHAR2(48)  Operating system program name 应用程序名称。
打开窗口依次执行如下命令:
启动当期sesison级别 跟踪
启动SQL跟踪
实例级别
Alter system set sql_trace=true  scope=both;
当期session级别
Alter session set sql_trace=true;

Execute dbms_session.set_sql_trace(true);
EXECUTE dbms_system.set_sql_trace_in_session
(session_id, serial_id, true);
 
 
 
 
 
 
 
 
 
Alter  session  set sql_trace=true;
执行待调试的语句
select c.code, nvl(b.con, 0)
  from t_sys_codemap c,
       (select COUNT(1) con, m.bljg
          from V_JC_XZXK_BUSI_TIMELIMIT t, V_JC_XZXK_BUSIINDEX m
         where t.busiindexid = m.ywlsh
           and t.LIMITTYPE = 1
           and trunc(m.tjsj) >= trunc(SYSDATE, 'year')
&nb


相关文档:

PL/SQL学习笔记四


事务是Oracle9i中进行数据库操作的基本单位,在PL/SQL程序中,可以使用3个事务处理控制命令。
1. commit命令
commit是事务提交命令。Oracle9i数据库中,为保证数据一致性,在内存中为每个客户机建立工作区,客户机对数据库进行操作的事务都在工作区完成,只有执行commit命令后,工作区内的修改内容才写入到数据库上,称 ......

PL/SQL学习笔记六


1.创建过程
create or replace procedure 过程名 as
   声明语句段;
begin
   执行语句段;
exception
   异常处理语句段;
end;
2. 带参数的过程
参数类型3种
in参数:读入参数,主程序向过程传递参数值
out参数:输出参数,过程向主程序传递参数值
in out参数:双向参数
定义 ......

SQL 日期函数集日期处理方法范例

--都写了 参考下吧
通常,你需要获得当前日期和计算一些其他的日期,例如,你的程序可能需要判断一个月的第一天或者最后一天。你们大部分人大概都知道怎样把日期进行分割(年、月、日等),然后仅仅用分割出来的年、月、日等放在几个函数中计算出自己所需要的日期!在这篇文章里,我将告诉你如何使用DATEADD和DATEDIFF函数 ......

SQL触发器

一个简单的小实例就明白~!
 user表
在这张表中建立触发器  
 Create   trigger   tiggername  
 on   user     
 for   delete     
 as   
 begin ......

SQL*Plus FAQ

 What is SQL*Plus and where does it come from?
SQL*Plus is a command line SQL and PL/SQL language interface and reporting tool that ships with the Oracle Database Client and Server software. It can be used interactively or driven from scripts. SQL*Plus is frequently used by DBAs and Developers ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号