WEB开发网
开发学院数据库Oracle 浅谈Oracle性能优化可能出现的问题 阅读

浅谈Oracle性能优化可能出现的问题

 2009-04-25 13:14:30 来源:WEB开发网   
核心提示: 上面的1000条是一个可以设定的数,根据你的服务器性能可以扩大或缩小,浅谈Oracle性能优化可能出现的问题(2),用exit跳出循环,通常情况下,exit只跳出当前层的循环,SQL>BEGIN2<>3FORv_outerloopcounterIN1..2LOOP4<

上面的1000条是一个可以设定的数,根据你的服务器性能可以扩大或缩小。

用exit跳出循环,通常情况下,exit只跳出当前层的循环,与其它程序设计语言的break语句类似。在嵌套的循环中,如果要直接从内层循环跳出外面多层的循环,可使用'EXIT 标签 When'形式的语句,举例如下:

SQL>   BEGIN   
2          <>   
3          FOR v_outerloopcounter IN 1..2 LOOP   
4               <>   
5               FOR v_innerloopcounter IN 1..4 LOOP   
6                    DBMS_OUTPUT.PUT_LINE('Outer Loop counter is '  
7                         || v_outerloopcounter ||   
8                         ' Inner Loop counter is ' || v_innerloopcounter);   
9                         EXIT WHEN v_innerloopcounter = 3;   
10              END LOOP innerloop;   
11         END LOOP outerloop;   
12    END;   
13    /   
Outer Loop counter is 1 Inner Loop counter is 1   
Outer Loop counter is 1 Inner Loop counter is 2   
Outer Loop counter is 1 Inner Loop counter is 3   
Outer Loop counter is 2 Inner Loop counter is 1   
Outer Loop counter is 2 Inner Loop counter is 2   
Outer Loop counter is 2 Inner Loop counter is 3   

PL/SQL procedure successfully completed.  

从上面可以看出,普通情况下,exit只跳出当前层的循环。

SQL>   BEGIN   
2          <>   
3          FOR v_outerloopcounter IN 1..2 LOOP   
4               <>   
5               FOR v_innerloopcounter IN 1..4 LOOP   
6                    DBMS_OUTPUT.PUT_LINE('Outer Loop counter is '  
7                         || v_outerloopcounter ||   
8                         ' Inner Loop counter is ' || v_innerloopcounter);   
9                         EXIT outerloop WHEN v_innerloopcounter = 3;   
10              END LOOP innerloop;   
11         END LOOP outerloop;   
12    END;   
13    /   
Outer Loop counter is 1 Inner Loop counter is 1   
Outer Loop counter is 1 Inner Loop counter is 2   
Outer Loop counter is 1 Inner Loop counter is 3   

PL/SQL procedure successfully completed. 

从上面可以看出,exit跳出了外层的循环。 

上一页  1 2 

Tags:Oracle 性能 优化

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接