[20240607]PL/SQL中sql語句的註解.txt
--//別人測試遇到的問題,重複測試說明問題.
1.環境:
SCOTT@test01p> @ ver
BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0
$ cat m2.sql
DECLARE
l_count PLS_INTEGER;
BEGIN
FOR i IN 1..&&1
LOOP
SELECT /*+ find_me */ COUNT(*) INTO L_COUNT FROM DEPT WHERE DEPTNO=10;
END LOOP;
END;
/
2.測試1:
--//session 1:
SCOTT@test01p> set timing on
SCOTT@test01p> @ m2.sql 10000
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.47
--//session 2:
SYS@test> select sql_id ,sql_text,executions from v$sql where sql_text like '%find_me%' and executions>=1e4;
SQL_ID SQL_TEXT EXECUTIONS
------------- ------------------------------------------------------------ ----------
b744uv7rtsf8t SELECT /*+ find_me */ COUNT(*) FROM DEPT WHERE DEPTNO=10 10000
3.繼續:
$ cat m3.sql
DECLARE
l_count PLS_INTEGER;
BEGIN
FOR i IN 1..&&1
LOOP
SELECT /* find_me */ COUNT(*) INTO L_COUNT FROM DEPT WHERE DEPTNO=10;
END LOOP;
END;
/
--//僅僅註解部分沒有+加號.
--//退出會話重新整理共享池:
SYS@test> alter system flush shared_pool;
System altered.
--//session 1:
SCOTT@test01p> @ m3.sql 30000
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.51
--//session 2:
SYS@test> select sql_id ,sql_text,executions from v$sql where sql_text like '%find_me%' and executions>=1e4;
no rows selected.
--//沒有發現包含find_me字串的sql語句.
--//而實際上匿名PL SQL做了特殊處理,刪除註解部分,真正執行的是:
--// SELECT COUNT(*) FROM DEPT WHERE DEPTNO=10
SYS@test> select sql_id ,sql_text,executions from v$sql where sql_id='9y1zzt1h1f3pz';
SQL_ID SQL_TEXT EXECUTIONS
------------- ------------------------------------------------------------ ----------
9y1zzt1h1f3pz SELECT COUNT(*) FROM DEPT WHERE DEPTNO=10 30000
--//簡單驗證:
--//session 1:
SCOTT@test01p> @ m3.sql 9999
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.39
--//session 2:
SYS@test> select sql_id ,sql_text,executions from v$sql where sql_id='9y1zzt1h1f3pz';
SQL_ID SQL_TEXT EXECUTIONS
------------- ------------------------------------------------------------ ----------
9y1zzt1h1f3pz SELECT COUNT(*) FROM DEPT WHERE DEPTNO=10 39999
--//如果註解部分沒有+,PL/SQL對於裡面的sql語句會作出特殊處理,取消註解,另外注意PL/SQL會格式化sql語句,這些在我以前blog提到.
[20240607]PL/SQL中sql語句的註解.txt
相關文章
- PL/SQL 條件控制語句SQL
- Oracle PL/SQL程式碼中的註釋OracleSQL
- [20201105]再分析sql語句.txtSQL
- [20220117]超長sql語句.txtSQL
- [20201210]sql語句優化.txtSQL優化
- Java中如何解析SQL語句、格式化SQL語句、生成SQL語句?JavaSQL
- 6.4. PL/SQL語法——6.4.5. 迴圈語句SQL
- [20240320]空格與sqlpus的sql語句.txtSQL
- [20200320]SQL語句優化的困惑.txtSQL優化
- [20211009]使用bash計算sql語句的sql_id.txtSQL
- Oracle SQL精妙SQL語句講解OracleSQL
- [20220331]如何調整sql語句.txtSQL
- [20191101]通過zsh計算sql語句的sql_id.txtSQL
- [20191011]通過bash計算sql語句的sql_id.txtSQL
- java-Mybatis 註解方式實現sql語句JavaMyBatisSQL
- [20181114]一條sql語句的優化.txtSQL優化
- [20211221]分析sql語句遇到的問題.txtSQL
- Oracle 的PL/SQL語言使用OracleSQL
- 20180417PLSQL中sql語句格式化與註解問題SQL
- 自定義註解例項實現SQL語句生成SQL
- springboot 中列印 sql 語句Spring BootSQL
- [20200324]SQL語句優化的困惑2.txtSQL優化
- [20210112]ashtop查詢特定表的SQL語句.txtSQL
- SQL語句SQL
- 【SQL】9 SQL INSERT INTO 語句SQL
- 【SQL】10 SQL UPDATE 語句SQL
- 【SQL】11 SQL DELETE 語句SQLdelete
- [20181119]sql語句執行緩慢分析.txtSQL
- [20220329]是否開發寫錯sql語句.txtSQL
- [20210923]sql語句佔用Sharable Memory分析.txtSQL
- SQL語句IN的用法SQL
- [20201214]查詢隱式轉換的sql語句.txtSQL
- 20201214]查詢隱式轉換的sql語句.txtSQL
- 註冊 sql語句+後端PHP檔案SQL後端PHP
- SQL SELECT 語句SQL
- sql常用語句SQL
- [20220111]該語句的sql_id如何計算的.txtSQL
- [20211224]vim外掛格式化sql語句.txtSQL