浅谈Oracle SQL trace

简介:

在生产环境中,当数据库运行异常缓慢的时候,DBA同学们都会想冲进数据库内部看看sql到底如何运行,为何语句执行的如此缓慢?在我的生产环境中,经常有多表关联查询语句运行缓慢,多数是I/O等待的问题,因而我第一步会去看sql的执行计划是否出现了问题,其次就会用到sql trace工具来跟踪下sql的实际运行情况!

一:使用sql_trace
1:产生select语句的trace文件,一般会使用tracefile_identifier给trace文件起一个标识性的名称,便于查找

 
  1. [oracle@dg53 ~]$ sqlplus /nolog  
  2. SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jun 8 11:53:36 2012  
  3. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  4.  
  5. SQL> conn hr/hr  
  6. Connected.  
  7.  
  8. SQL> alter session set tracefile_identifier='hr_trace01';  
  9. Session altered.  
  10.  
  11. SQL> alter session set sql_trace=true;  
  12. Session altered.  
  13.  
  14. SQL> select salary,last_name from employees where employee_id=100;  
  15.  
  16.     SALARY LAST_NAME  
  17. ---------- -------------------------  
  18.       2000 King  
  19.  
  20. SQL> alter session set sql_trace=false;  
  21. Session altered.  
  22.  
  23. [oracle@dg53 ~]$ cd $ORACLE_BASE/admin/orcl10g/udump/  
  24. [oracle@dg53 udump]$ ll *hr*  
  25. -rw-r----- 1 oracle oinstall 89149 Jun  8 11:58 dg53_ora_10498_hr_trace01.trc 

2:使用tkprof工具对产生的trace文件进行过滤,抽取有用的信息,默认的trace文件输出太多信息!
sys=no代表不输出trace文件中所有sys用户的操作,包含用户sql语句引起的递归sql,使输出变的简洁;
aggragate=yes代表相同的sql语句在输入文件中做合并,使输出变的简洁;

[oracle@dg53 udump]$ tkprof dg53_ora_10498_hr_trace01.trc /home/oracle/trace01.log   aggregate=yes sys=no explain=hr/hr

[oracle@dg53 udump]$ wc -l dg53_ora_10498_hr_trace01.trc 
1097 dg53_ora_10498_hr_trace01.trc
[oracle@dg53 udump]$ wc -l /home/oracle/trace01.log 
137 /home/oracle/trace01.log

[oracle@dg53 ~]$ cat trace01.log 
TKPROF: Release 10.2.0.1.0 - Production on Fri Jun 8 12:06:23 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Trace file: dg53_ora_10498_hr_trace01.trc
Sort options: default

********************************************************************************
count    = number of times OCI procedure was executed
cpu      = cpu time in seconds executing 
elapsed  = elapsed time in seconds executing
disk     = number of physical reads of buffers from disk
query    = number of buffers gotten for consistent read
current  = number of buffers gotten in current mode (usually for update)
rows     = number of rows processed by the fetch or execute call
********************************************************************************
alter session set sql_trace=true

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        0      0.00       0.00          0          0          0           0
Execute      1      0.00       0.01          0          0          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        1      0.00       0.01          0          0          0           0

Misses in library cache during parse: 0
Misses in library cache during execute: 1 
Optimizer mode: ALL_ROWS
Parsing user id: 55  (HR)
********************************************************************************
select salary,last_name 
from
 employees where employee_id=100

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.02          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.00       0.01          2          2          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.00       0.04          2          2          0           1

Misses in library cache during parse: 1  (表示该sql语句执行了硬解析,未在库缓存中命中)
Optimizer mode: ALL_ROWS    (CBO的模式,表示尽可能快的输出全部的结果集,oltp系统分页条
件下普遍使用first_rows)
Parsing user id: 55  (HR)

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  TABLE ACCESS BY INDEX ROWID EMPLOYEES (cr=2 pr=2 pw=0 time=18516 us)
      1   INDEX UNIQUE SCAN EMP_EMP_ID_PK (cr=1 pr=1 pw=0 time=11715 us)(object id

51859)

Rows     Execution Plan (因为在使用tkprof分析trace文件的时候使用了explain参数,所以有执行计划输出)
-------  ---------------------------------------------------
      0  SELECT STATEMENT   MODE: ALL_ROWS
      1   TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF 'EMPLOYEES' 
              (TABLE)
      1    INDEX   MODE: ANALYZED (UNIQUE SCAN) OF 'EMP_EMP_ID_PK' (INDEX 
               (UNIQUE))

********************************************************************************
alter session set sql_trace=false

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.00       0.00          0          0          0           0

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 55  (HR)

********************************************************************************
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        2      0.00       0.02          0          0          0           0
Execute      3      0.00       0.01          0          0          0           0
Fetch        2      0.00       0.01          2          2          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        7      0.00       0.05          2          2          0           1

Misses in library cache during parse: 2
Misses in library cache during execute: 1

OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse       21      0.01       0.02          0          0          0           0
Execute    122      0.03       0.03          0          0          0           0
Fetch      173      0.01       0.16         18        419          0         633
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total      316      0.06       0.22         18        419          0         633

Misses in library cache during parse: 15
Misses in library cache during execute: 15

    3  user  SQL statements in session.
  122  internal SQL statements in session.
  125  SQL statements in session.
    1  statement EXPLAINed in this session.
********************************************************************************
Trace file: dg53_ora_10498_hr_trace01.trc
Trace file compatibility: 10.01.00
Sort options: default

       1  session in tracefile.
       3  user  SQL statements in trace file.
     122  internal SQL statements in trace file.
     125  SQL statements in trace file.
      18  unique SQL statements in trace file.
       1  SQL statements EXPLAINed using schema:
           HR.prof$plan_table
             Default table was used.
             Table was created.
             Table was dropped.
    1097  lines in trace file.
      38  elapsed seconds in trace file.

二:10046事件
10046事件按照收集的信息内容,分为4个级别
level1: 等同于前面介绍的sql_trace
level4: 在level1的基础上增加绑定变量的收集
level8: 在level1的基础上增加等待事件的收集
level12: 等同于level4+level8(所以这个级别用的最普遍)

 
 
SQL
>
 alter session set 
tracefile_identifier
=
'hr_trace02'
;   
Session altered.   
  
SQL
>
 var id number   
SQL
>
 exec :id 
:

200
  
PL/SQL procedure successfully completed.   
  
SQL
>
 alter session set events '10046 trace name context forever,level 12';   
Session altered.   
  
SQL
>
 select salary from employees where 
employee_id
=:id;   
  
    SALARY   
----------   
      4400   
  
SQL
>
 alter session set events '10046 trace name context off';   
Session altered.   
  
[oracle@dg53 udump]$ ll *hr*   
-rw-r----- 1 oracle oinstall 89149 Jun  8 11:58 dg53_ora_10498_hr_trace01.trc   
-rw-r----- 1 oracle oinstall  3034 Jun  8 14:28 dg53_ora_18857_hr_trace02.trc   
  
[oracle@dg53 udump]$ tkprof dg53_ora_18857_hr_trace02.trc /home/oracle/trace02.log    
  
sys
=
no
 
aggregate
=
yes
 
explain
=
hr
/hr  

[oracle@dg53 udump]$ cat /home/oracle/trace02.log (tkprof处理后将看不到绑定变量信息)
TKPROF: Release 10.2.0.1.0 - Production on Fri Jun 8 14:31:46 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Trace file: dg53_ora_18857_hr_trace02.trc
Sort options: default

********************************************************************************
count    = number of times OCI procedure was executed
cpu      = cpu time in seconds executing 
elapsed  = elapsed time in seconds executing
disk     = number of physical reads of buffers from disk
query    = number of buffers gotten for consistent read
current  = number of buffers gotten in current mode (usually for update)
rows     = number of rows processed by the fetch or execute call
********************************************************************************

alter session set events '10046 trace name context forever,level 12'


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        0      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        1      0.00       0.00          0          0          0           0 

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 55  (HR)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00
********************************************************************************

select salary 
from
 employees where employee_id=:id

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.00       0.01          1          2          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.00       0.01          1          2          0           1

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 55  (HR)

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  TABLE ACCESS BY INDEX ROWID EMPLOYEES (cr=2 pr=1 pw=0 time=16216 us)
      1   INDEX UNIQUE SCAN EMP_EMP_ID_PK (cr=1 pr=0 pw=0 time=128 us)(object id 51859)
 

Rows     Execution Plan
-------  ---------------------------------------------------
      0  SELECT STATEMENT   MODE: ALL_ROWS
      1   TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF 'EMPLOYEES' 
              (TABLE)
      1    INDEX   MODE: ANALYZED (UNIQUE SCAN) OF 'EMP_EMP_ID_PK' (INDEX 
               (UNIQUE))

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       2        0.00          0.00
  db file sequential read                         1        0.01          0.01
  SQL*Net message from client                     2        0.00          0.00
********************************************************************************
 

alter session set events '10046 trace name context off'

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.00       0.00          0          0          0           0

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 55  (HR)

********************************************************************************

OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        2      0.00       0.00          0          0          0           0
Execute      3      0.00       0.00          0          0          0           0
Fetch        2      0.00       0.01          1          2          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        7      0.00       0.01          1          2          0           1

Misses in library cache during parse: 0

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       5        0.00          0.00
  SQL*Net message from client                     5       10.32         15.71
  db file sequential read                         1        0.01          0.01
 

OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS 

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        0      0.00       0.00          0          0          0           0
Execute      0      0.00       0.00          0          0          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        0      0.00       0.00          0          0          0           0

Misses in library cache during parse: 0

    3  user  SQL statements in session.
    0  internal SQL statements in session.
    3  SQL statements in session.
    1  statement EXPLAINed in this session.
********************************************************************************
Trace file: dg53_ora_18857_hr_trace02.trc
Trace file compatibility: 10.01.00
Sort options: default

       0  session in tracefile.
       3  user  SQL statements in trace file.
       0  internal SQL statements in trace file.
       3  SQL statements in trace file.
       3  unique SQL statements in trace file.
       1  SQL statements EXPLAINed using schema:
           HR.prof$plan_table
             Default table was used.
             Table was created.
             Table was dropped.
      46  lines in trace file.
      15  elapsed seconds in trace file.
 

[oracle@dg53 udump]$ head -30 dg53_ora_18857_hr_trace02.trc
/u01/app/oracle/admin/orcl10g/udump/dg53_ora_18857_hr_trace02.trc
 

*** TRACE DUMP CONTINUED FROM FILE

/u01/app/oracle/admin/orcl10g/udump/dg53_ora_18857_hr_trace02.trc ***

*** 2012-06-08 14:28:26.627
=====================
PARSING IN CURSOR #2 len=68 dep=0 uid=55 oct=42 lid=55 tim=1307750885378875

hv=2804619552 ad='2349fc80'
alter session set events '10046 trace name context forever,level 12'
END OF STMT
EXEC #2:c=0,e=107,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=1307750885378870
WAIT #2: nam='SQL*Net message to client' ela= 2 driver id=1650815232 #bytes=1 p3=0

obj#=-1 tim=1307750885378967
WAIT #2: nam='SQL*Net message from client' ela= 126 driver id=1650815232 #bytes=1 p3=0

obj#=-1 tim=1307750885379118
WAIT #0: nam='SQL*Net message to client' ela= 1 driver id=1650815232 #bytes=1 p3=0

obj#=-1 tim=1307750885379173
WAIT #0: nam='SQL*Net message from client' ela= 5384831 driver id=1650815232 #bytes=1

p3=0 obj#=-1 tim=1307750890764022
=====================
PARSING IN CURSOR #3 len=50 dep=0 uid=55 oct=3 lid=55 tim=1307750890764197 
 hv=2273608758 ad='2349fa44'
select salary from employees where employee_id=:id
END OF STMT
PARSE #3:c=0,e=96,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=1307750890764193
BINDS #3:
kkscoacd
 Bind#0
  oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00
  oacflg=03 fl2=1000000 frm=00 csi=00 siz=24 off=0
  kxsbbbfp=b7fb9ad0  bln=22  avl=02  flg=05
  value=200
EXEC #3:c=0,e=334,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=1307750890764600
WAIT #3: nam='SQL*Net message to client' ela= 2 driver id=1650815232 #bytes=1 p3=0 
 obj#=-1 tim=1307750890764630
WAIT #3: nam='db file sequential read' ela= 13073 file#=5 block#=84 blocks=1 obj#=51857
 tim=1307750890780678
FETCH #3:c=5999,e=16119,p=1,cr=2,cu=0,mis=0,r=1,dep=0,og=1,tim=1307750890780769
 

 三:其他用户的会话进行跟踪
1:针对其他用户的sql_trace跟踪

 
  1. C:\>sqlplus hr/hr@192.168.123.13:1521/dg53.yang.com  
  2. SQL*Plus: Release 11.2.0.3.0 Production on Fri Jun 8 14:46:33 2012  
  3. Copyright (c) 1982, 2011, Oracle.  All rights reserved.  
  4.  
  5. Connected to:  
  6. Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production  
  7. With the Partitioning, OLAP and Data Mining options  
  8.  
  9. SQL> show user;  
  10. USER is "HR"  
  11.  
  12. SQL> show user;  
  13. USER is "SYS"  
  14. SQL> select sid,serial# from v$session where username='HR';  
  15.  
  16.        SID    SERIAL#  
  17. ---------- ----------  
  18.        129         55  
  19.  
  20. SQL> select p.spid from v$session s,v$process p where s.paddr=p.addr and s.sid=129 and   
  21.  
  22. s.serial#=55;  
  23.  
  24. SPID  
  25. ------------  
  26. 20844  
  27.  
  28. SQL> exec dbms_system.set_sql_trace_in_session(129,55,true);  
  29. PL/SQL procedure successfully completed.  
  30.  
  31. SQL> select distinct department_id from departments;  
  32.  
  33. DEPARTMENT_ID  
  34. -------------  
  35.            10  
  36.            20  
  37.            30  
  38.            40  
  39.  
  40. SQL> exec dbms_system.set_sql_trace_in_session(129,55,false);  
  41. PL/SQL procedure successfully completed.  
  42.  
  43. [oracle@dg53 udump]$ tkprof dg53_ora_20844.trc /home/oracle/trace03.log sys=no   
  44.  
  45. aggregate=yes explain=hr/hr 

2:针对其他会话的10046事件的开启和关闭

 
  1. SQL> exec dbms_monitor.session_trace_enable(129,55,waits=>true,binds=>true);  
  2. PL/SQL procedure successfully completed.  
  3.  
  4. SQL> exec dbms_monitor.session_trace_disable(129,55);  
  5. PL/SQL procedure successfully completed 

 本文以《让oracle跑的更快》为指导,如有雷同,不胜荣幸!

本文转自斩月博客51CTO博客,原文链接http://blog.51cto.com/ylw6006/895017如需转载请自行联系原作者


ylw6006

相关文章
|
19天前
|
SQL Oracle 关系型数据库
Oracle的PL/SQL隐式游标:数据的“自动导游”与“轻松之旅”
【4月更文挑战第19天】Oracle PL/SQL中的隐式游标是自动管理的数据导航工具,简化编程工作,尤其适用于简单查询和DML操作。它自动处理数据访问,提供高效、简洁的代码,但不适用于复杂场景。显式游标在需要精细控制时更有优势。了解并适时使用隐式游标,能提升数据处理效率,让开发更加轻松。
|
19天前
|
SQL Oracle 关系型数据库
Oracle的PL/SQL游标自定义异常:数据探险家的“专属警示灯”
【4月更文挑战第19天】Oracle PL/SQL中的游标自定义异常是处理数据异常的有效工具,犹如数据探险家的警示灯。通过声明异常名(如`LOW_SALARY_EXCEPTION`)并在满足特定条件(如薪资低于阈值)时使用`RAISE`抛出异常,能灵活应对复杂业务规则。示例代码展示了如何在游标操作中定义和捕获自定义异常,提升代码可读性和维护性,确保在面对数据挑战时能及时响应。掌握自定义异常,让数据管理更从容。
|
19天前
|
SQL Oracle 安全
Oracle的PL/SQL游标异常处理:从“惊涛骇浪”到“风平浪静”
【4月更文挑战第19天】Oracle PL/SQL游标异常处理确保了在数据操作中遇到的问题得以优雅解决,如`NO_DATA_FOUND`或`TOO_MANY_ROWS`等异常。通过使用`EXCEPTION`块捕获并处理这些异常,开发者可以防止程序因游标问题而崩溃。例如,当查询无结果时,可以显示定制的错误信息而不是让程序终止。掌握游标异常处理是成为娴熟的Oracle数据管理员的关键,能保证在复杂的数据环境中稳健运行。
|
19天前
|
SQL Oracle 安全
Oracle的PL/SQL异常处理方法:守护数据之旅的“魔法盾”
【4月更文挑战第19天】Oracle PL/SQL的异常处理机制是保障数据安全的关键。通过预定义异常(如`NO_DATA_FOUND`)和自定义异常,开发者能优雅地管理错误。异常在子程序中抛出后会向上传播,直到被捕获,提供了一种集中处理错误的方式。理解和善用异常处理,如同手持“魔法盾”,确保程序在面对如除数为零、违反约束等挑战时,能有效保护数据的完整性和程序的稳定性。
|
19天前
|
SQL Oracle 关系型数据库
Oracle的PL/SQL中FOR语句循环游标的奇幻之旅
【4月更文挑战第19天】在Oracle PL/SQL中,FOR语句与游标结合,提供了一种简化数据遍历的高效方法。传统游标处理涉及多个步骤,而FOR循环游标自动处理细节,使代码更简洁、易读。通过示例展示了如何使用FOR循环游标遍历员工表并打印姓名和薪资,对比传统方式,FOR语句不仅简化代码,还因内部优化提升了执行效率。推荐开发者利用这一功能提高工作效率。
|
19天前
|
SQL Oracle 关系型数据库
Oracle的PL/SQL游标属性:数据的“导航仪”与“仪表盘”
【4月更文挑战第19天】Oracle PL/SQL游标属性如同车辆的导航仪和仪表盘,提供丰富信息和控制。 `%FOUND`和`%NOTFOUND`指示数据读取状态,`%ROWCOUNT`记录处理行数,`%ISOPEN`显示游标状态。还有`%BULK_ROWCOUNT`和`%BULK_EXCEPTIONS`增强处理灵活性。通过实例展示了如何在数据处理中利用这些属性监控和控制流程,提高效率和准确性。掌握游标属性是提升数据处理能力的关键。
|
19天前
|
SQL Oracle 关系型数据库
Oracle的PL/SQL显式游标:数据的“私人导游”与“定制之旅”
【4月更文挑战第19天】Oracle PL/SQL中的显式游标提供灵活精确的数据访问,与隐式游标不同,需手动定义、打开、获取和关闭。通过DECLARE定义游标及SQL查询,OPEN启动查询,FETCH逐行获取数据,CLOSE释放资源。显式游标适用于复杂数据处理,但应注意SQL效率、游标管理及异常处理。它是数据海洋的私人导游,助力实现业务逻辑和数据探险。
|
19天前
|
SQL 存储 Oracle
Oracle的PL/SQL游标:数据的“探秘之旅”与“寻宝图”
【4月更文挑战第19天】Oracle PL/SQL游标是数据探索的关键工具,用于逐行访问结果集。它的工作原理包括定义、打开、FETCH和关闭,允许灵活处理数据。游标有隐式和显式两种类型,适用于不同场景,且支持参数化以增强灵活性。尽管游标在数据处理中不可或缺,但过度使用可能影响性能,因此需谨慎优化。掌握游标技巧,能有效实现业务逻辑,开启数据世界的探秘之旅。
|
19天前
|
SQL Oracle 安全
Oracle的PL/SQL循环语句:数据的“旋转木马”与“无限之旅”
【4月更文挑战第19天】Oracle PL/SQL中的循环语句(LOOP、EXIT WHEN、FOR、WHILE)是处理数据的关键工具,用于批量操作、报表生成和复杂业务逻辑。LOOP提供无限循环,可通过EXIT WHEN设定退出条件;FOR循环适用于固定次数迭代,WHILE循环基于条件判断执行。有效使用循环能提高效率,但需注意避免无限循环和优化大数据处理性能。掌握循环语句,将使数据处理更加高效和便捷。
|
SQL Oracle 关系型数据库
oracle用SQL Plus输入命令为什么只显示2
oracle用SQL Plus输入命令为什么只显示2
471 0
oracle用SQL Plus输入命令为什么只显示2

推荐镜像

更多