[20161230]檢視父遊標中sql語句.txt
[20161230]檢視父遊標中sql語句.txt
--上午巡檢完,無聊,測試使用oradebug下檢視sql語句在父遊標中的內容.sql語句在執行第一次硬解析時生成父子游標,其中父遊標chunk
--中儲存sql語句,測試透過oradebug下如何檢視:
1.環境:
SCOTT@book> select * from dept where deptno=10;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
--多執行幾次,保持sql語句游標在共享池中,確定sql_id= 4xamnunv51w9j.
SYS@book> @ &r/sharepool/shp4 4xamnunv51w9j 0
old 17: WHERE kglobt03 = '&1' or kglhdpar='&1' or kglhdadr='&1' or KGLNAHSH= &2
new 17: WHERE kglobt03 = '4xamnunv51w9j' or kglhdpar='4xamnunv51w9j' or kglhdadr='4xamnunv51w9j' or KGLNAHSH= 0
TEXT KGLHDADR KGLHDPAR C40 KGLOBHD0 KGLOBHD6 KGLOBHS0 KGLOBHS6 KGLOBT16 N0_6_16 N20 KGLNAHSH KGLOBT03 KGLOBT09
-------------- ---------------- ---------------- ---------------------------------------- ---------------- ---------------- ---------- ---------- ---------- --------- ---------- ---------- ------------- ----------
子游標控制程式碼地址 000000007BE4DDB8 000000007D1B5D98 select * from dept where deptno=10 000000007CBCC6D0 000000007BA5D690 4560 12144 3067 19771 19771 911274289 4xamnunv51w9j 0
父遊標控制程式碼地址 000000007D1B5D98 000000007D1B5D98 select * from dept where deptno=10 000000007B5E7E88 00 4720 0 0 4720 4720 911274289 4xamnunv51w9j 65535
--父遊標地址=000000007D1B5D98
2.看看範圍:
> SELECT * FROM x$ksmsp WHERE TO_NUMBER ('000000007D1B5D98', 'xxxxxxxxxxxxxxxx') between TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx') and TO_NUMBER(KSMCHPTR, 'xxxxxxxxxxxxxxxx')+KSMCHSIZ
ADDR INDX INST_ID KSMCHIDX KSMCHDUR KSMCHCOM KSMCHPTR KSMCHSIZ KSMCHCLS KSMCHTYP KSMCHPAR
---------------- ---------- ---------- ---------- ---------- ---------------- ---------------- ---------- -------- ---------- ----------------
00007FFD8A3FB4B8 9505 1 1 1 KGLHD 000000007D1B5D68 560 recr 80 00
--可以確定範圍: 0x00007F6F855B1CB0 ,0x00007F6F855B1CB0+560.
--//先看看sql語句轉儲的內容:
SCOTT@book> select dump('select * from dept where deptno=10',16) from dual ;
DUMP('SELECT*FROMDEPTWHEREDEPTNO=10',16)
--------------------------------------------------------------------------------------------------------------------
Typ=96 Len=34: 73,65,6c,65,63,74,20,2a,20,66,72,6f,6d,20,64,65,70,74,20,77,68,65,72,65,20,64,65,70,74,6e,6f,3d,31,30
--//我使用的cpu是intel系列的,存在大小頭問題,在記憶體中看到的應該4個位元組4個位元組顛倒.前面4個應該是65,6c,65,73(16進位制).
--//BTW: 我的測試oradebug peek最多查詢60個位元組.
SYS@book> oradebug peek 0x000000007D1B5D98 64
[07D1B5D98, 07D1B5DD8) = 807CBD30 00000000 807CBD30 00000000 7BA5CFD0 00000000 7D1B5EF0 00000000 00010000 10012841 00000001 00000001 00010001 00000002 ...
SYS@book> oradebug peek 0x000000007D1B5D98 60
[07D1B5D98, 07D1B5DD4) = 807CBD30 00000000 807CBD30 00000000 7BA5CFD0 00000000 7D1B5EF0 00000000 00010000 10012841 00000001 00000001 00010001 00000002 00000000
3.繼續測試:
SCOTT@book> select 'oradebug peek '|| to_char(TO_NUMBER ('000000007D1B5D98', 'xxxxxxxxxxxxxxxx')+(rownum-1)*60)||' 60;' c40 from dual connect by level<=10;
C40
----------------------------------------
oradebug peek 2098945432 60;
oradebug peek 2098945492 60;
oradebug peek 2098945552 60;
oradebug peek 2098945612 60;
oradebug peek 2098945672 60;
oradebug peek 2098945732 60;
oradebug peek 2098945792 60;
oradebug peek 2098945852 60;
oradebug peek 2098945912 60;
oradebug peek 2098945972 60;
10 rows selected.
--60*9+20=560,修改最好一行oradebug peek 2098945972 20;執行如下:
oradebug setmypid
spool aa.txt
oradebug peek 2098945432 60;
oradebug peek 2098945492 60;
oradebug peek 2098945552 60;
oradebug peek 2098945612 60;
oradebug peek 2098945672 60;
oradebug peek 2098945732 60;
oradebug peek 2098945792 60;
oradebug peek 2098945852 60;
oradebug peek 2098945912 60;
oradebug peek 2098945972 20;
spool off
$ cat aa.txt | grep -i 656c6573
[07D1B5F3C, 07D1B5F78) = 00000053 656C6573 2A207463 6F726620 6564206D 77207470 65726568 70656420 3D6F6E74 00003031 00000000 00000000 00000000 00000000 00000000
--//可以確定偏移量是0x07D1B5F40.
SYS@book> oradebug peek 0x07D1B5F40 60
[07D1B5F40, 07D1B5F7C) = 656C6573 2A207463 6F726620 6564206D 77207470 65726568 70656420 3D6F6E74 00003031 00000000 00000000 00000000 00000000 00000000 00000000
--//7D1B5F40 = 2098945856
--//7D1B5D68 = 2098945384
--//2098945856-2098945384=472
--偏移在472的位置.
$ echo "656C6573 2A207463 6F726620 6564206D 77207470 65726568 70656420 3D6F6E74 00003031"| xxd -r -p | od -t x4 | cut -c9- | xxd -r -p ;echo
select * from dept where deptno=10
--對比sql語句正好吻合
$ cut -f2 -d= aa.txt | sed 's/ //g'| xxd -r -p | od -t x4 -v | cut -c9- | xxd -r -p >| aa.bin
$ ls -l aa.bin
-rw-r--r-- 1 oracle oinstall 560 2016-12-30 09:28:32 aa.bin
$ xxd -c 32 aa.bin
0000000: 30bd 7c80 0000 0000 30bd 7c80 0000 0000 d0cf a57b 0000 0000 f05e 1b7d 0000 0000 0.|.....0.|.....邢.{....館.}....
0000020: 0000 0100 4128 0110 0100 0000 0100 0000 0100 0100 0200 0000 0000 0000 0d00 0000 ....A(..........................
0000040: 0000 0100 0000 0000 0000 0000 0000 0000 685f 1b7d 0000 0000 0100 0000 0000 0000 ................h_.}............
0000060: f85d 1b7d 0000 0000 f85d 1b7d 0000 0000 085e 1b7d 0000 0000 085e 1b7d 0000 0000 鴀.}....鴀.}.....^.}.....^.}....
0000080: 7069 2c7d 0000 0000 7069 2c7d 0000 0000 285e 1b7d 0000 0000 285e 1b7d 0000 0000 pi,}....pi,}....(^.}....(^.}....
00000a0: e008 617e 0000 0000 e008 617e 0000 0000 0000 0000 0000 0000 0100 0000 0000 0000 ?a~....?a~....................
00000c0: d574 aa4e 0000 0000 31f1 0000 0000 0000 d85e 1b7d 0000 0000 705e 1b7d 0000 0000 誸狽....1?.....豝.}....p^.}....
00000e0: 705e 1b7d 0000 0000 805e 1b7d 0000 0000 805e 1b7d 0000 0000 0000 0000 0000 0000 p^.}.....^.}.....^.}............
0000100: 68ff 0680 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0300 0000 0100 0000 h?..............................
0000120: 0200 0200 0000 0000 0100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ................................
0000140: 0000 0000 0000 0000 2e00 0000 0000 0000 31f1 5036 0000 0000 5dc4 3114 e7b9 dbbd ................1馪6....]?.??
0000160: d574 aa4e 31f1 5036 0000 0000 7874 0c1e 0921 2f00 0000 0000 0000 0000 0000 0000 誸狽1馪6....xt...!/.............
0000180: 2300 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 405f 1b7d 0000 0000 #.......................@_.}....
00001a0: 31f1 5036 5300 0000 7365 6c65 6374 202a 2066 726f 6d20 6465 7074 2077 6865 7265 1馪6S...select * from dept where
00001c0: 2064 6570 746e 6f3d 3130 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 deptno=10......................
00001e0: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ................................
0000200: 0102 0000 008f b380 685d 1b7d 0000 0000 f893 1e7d 0000 0000 3007 8b7d 0000 0000 ........h].}....?.}....0..}....
0000220: 0000 0000 0000 0000 0000 0000 5000 0000 ...........
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2131655/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 檢視低效的SQL語句SQL
- SQL語句的解析過程 遊標週期SQL
- 關於sql語句的遊標共享問題SQL
- 20140321]檢視大量消耗資源的sql語句.txtSQL
- sql server中如何檢視執行效率不高的語句SQLServer
- 使用遊標迴圈進行SQL更新插入的SQL語句SQL
- sql 語句網路除錯和 sql 語句低層傳輸檢視SQL除錯
- 檢視mysql正在執行的SQL語句MySql
- SQL語句大全—檢視錶空間(二)SQL
- SQL語句大全—檢視錶空間(一)SQL
- 資料庫基礎知識詳解四:儲存過程、檢視、遊標、SQL語句優化以及索引資料庫儲存過程SQL優化索引
- Oracle 檢視佔用undo大的sql語句OracleSQL
- sqlserver 檢視和sql語句的效率對比SQLServer
- 檢視造成等待事件的具體SQL語句事件SQL
- v$sql v$sqlarea和父遊標 子游標記載01SQL
- [20200417]跟蹤特定sql語句以及v$open_cursor檢視.txtSQL
- v$sql v$sqlarea v$sql_shared_cursor及父遊標,子游標SQL
- 檢視v$sql_shared_cursor檢視獲取sql語句為什麼不能共享?SQL
- MySQL_通過binlog檢視原始SQL語句MySql
- 檢視包正在被哪個程式使用,檢視包含SQL語句的PACKAGESQLPackage
- MySQL 遊標(PREPARE預處理語句)MySql
- [20190125]簡單快速檢視那些sql語句正在執行.txtSQL
- Java中如何解析SQL語句、格式化SQL語句、生成SQL語句?JavaSQL
- Oracle遊標共享,父遊標和子游標的概念Oracle
- [20240607]PL/SQL中sql語句的註解.txtSQL
- 用LinqPad檢視Nhibernate生成的sql語句SQL
- 檢視mysql連線數 sql語句執行時間MySql
- 檢視當前oracle中正在執行的sql語句OracleSQL
- [20160215]超長sql語句與父子游標.txtSQL
- MySQL檢視建表語句MySql
- oracle 檢視死鎖語句Oracle
- [20200417]跟蹤特定sql語句以及v$open_cursor檢視2.txtSQL
- [20150403]修正sql語句.txtSQL
- 通過日誌檢視mysql正在執行的SQL語句MySql
- [20200424]跟蹤特定sql語句以及v$open_cursor檢視(再補充).txtSQL
- [20200422]跟蹤特定sql語句以及v$open_cursor檢視(補充).txtSQL
- [20120216]檢視資料庫整體效能問題sql語句.txt資料庫SQL
- sql 中的with 語句使用SQL