[20171110]sql語句相同sql_id可以不同嗎
[20171110]sql語句相同sql_id可以不同嗎.txt
--//提一個問題,就是sql語句相同sql_id可以不同嗎?
--//使用dbms_shared_pool.markhot就可以做到.
1.環境:
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SCOTT@book> select * from dept where deptno=10;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
--//sql_id='4xamnunv51w9j',可以執行多次,避免sql語句退出共享池.
SCOTT@book> select name,hash_value, full_hash_value, namespace, child_latch, property hot_flag, executions, invalidations from v$db_object_cache where name='select * from dept where deptno=10';
NAME HASH_VALUE FULL_HASH_VALUE NAMESPACE CHILD_LATCH HOT_FLAG EXECUTIONS INVALIDATIONS
---------------------------------------- ---------- -------------------------------- -------------------- ----------- ---------- ---------- -------------
select * from dept where deptno=10 911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA 0 7 0
select * from dept where deptno=10 911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA 61745 7 0
--//確定FULL_HASH_VALUE='1431c45dbddbb9e74eaa74d53650f131'.
2.設定markhot.
SYS@book> exec dbms_shared_pool.markhot( hash=>'1431c45dbddbb9e74eaa74d53650f131', namespace=>0, global=>true);
PL/SQL procedure successfully completed.
SCOTT@book> select name,hash_value, full_hash_value, namespace, child_latch, property hot_flag, executions, invalidations from v$db_object_cache where name='select * from dept where deptno=10';
NAME HASH_VALUE FULL_HASH_VALUE NAMESPACE CHILD_LATCH HOT_FLAG EXECUTIONS INVALIDATIONS
---------------------------------------- ---------- -------------------------------- -------------------- ----------- ---------- ---------- -------------
select * from dept where deptno=10 911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA 0 HOT 6 0
select * from dept where deptno=10 911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA 61745 HOT 6 0
--//HOT_FLAG='HOT'.
--//退出會話在執行如下:
SCOTT@book> select * from dept where deptno=10;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
SCOTT@book> select name,hash_value, full_hash_value, namespace, child_latch, property hot_flag, executions, invalidations from v$db_object_cache where name='select * from dept where deptno=10';
NAME HASH_VALUE FULL_HASH_VALUE NAMESPACE CHILD_LATCH HOT_FLAG EXECUTIONS INVALIDATIONS
---------------------------------------- ---------- -------------------------------- -------------------- ----------- -------------------- ---------- -------------
select * from dept where deptno=10 2941143312 5196d0b7fe72e5ea7c59eeb2af4e4910 SQL AREA 0 HOTCOPY11 3 0
select * from dept where deptno=10 2941143312 5196d0b7fe72e5ea7c59eeb2af4e4910 SQL AREA 18704 HOTCOPY11 3 0
select * from dept where deptno=10 911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA 0 HOT 6 0
select * from dept where deptno=10 911274289 1431c45dbddbb9e74eaa74d53650f131 SQL AREA 61745 HOT 6 0
--//可以發現FULL_HASH_VALUE多了一個5196d0b7fe72e5ea7c59eeb2af4e4910.HOT_FLAG='HOTCOPY11'.
SCOTT@book> select sql_id,sql_text,executions,length(sql_text),ora_hash(sql_text) from v$sqlarea where sql_text = 'select * from dept where deptno=10' ;
SQL_ID SQL_TEXT EXECUTIONS LENGTH(SQL_TEXT) ORA_HASH(SQL_TEXT)
------------- ------------------------------------------------------------ ---------- ---------------- ------------------
7sqgfqarnwk8h select * from dept where deptno=10 3 34 156172166
4xamnunv51w9j select * from dept where deptno=10 7 34 156172166
--//可以發現兩個sql_id不一樣,函式ora_hash(sql_text)的結果一樣.而執行的sql語句相同.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2147197/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 有相同sql_id的sql語句SQL
- 釋出博文 Oracle11g 相同SQL在不同資料庫中sql_hash_value, sql_id 相同OracleSQL資料庫
- [20150724]無法通過sql_id找到sql語句.txtSQL
- 5.7 與 8.0 對相同檔案的 LOAD DATA 語句結果不同
- [20150803]無法通過sql_id找到sql語句2.txtSQL
- [20150803]無法通過sql_id找到sql語句3.txtSQL
- SQL語句連軟解析都可以避免?SQL
- SQL語句SQL
- Java中如何解析SQL語句、格式化SQL語句、生成SQL語句?JavaSQL
- [轉][資料庫SQL語句]truncate/delete/drop同與不同資料庫SQLdelete
- 相同update語句在MySQL,Oracle的不同表現(r12筆記第30天)MySqlOracle筆記
- sql語句大全SQL
- 共享SQL語句SQL
- SQL語句整理SQL
- SQL基本語句SQL
- 精妙Sql語句SQL
- SQL語句集合SQL
- oracle sql語句OracleSQL
- sql語句 求救!SQL
- SQL精妙語句SQL
- SQL語句收集SQL
- 常用SQL語句SQL
- sql常用語句SQL
- Oracle環境下SQL語句的不同寫法效率對比OracleSQL
- 問題:V$SESSION SQL_ID 為空,找不到SQL_IDSessionSQL
- 【SQL】10 SQL UPDATE 語句SQL
- 【SQL】11 SQL DELETE 語句SQLdelete
- [20220111]該語句的sql_id如何計算的.txtSQL
- 【SQL】9 SQL INSERT INTO 語句SQL
- Java 可以採用什麼語句跳出迴圈語句Java
- 1.3. SQL 語句SQL
- Sql語句小整理SQL
- SQL語句優化SQL優化
- SQL SELECT 語句SQL
- SQL 語句學習SQL
- SQL語句IN的用法SQL
- Oracle基本SQL語句OracleSQL
- 重拾Sql語句SQL