[20181120]奇怪的insert語句.txt
[20181120]奇怪的insert語句.txt
--//上午檢查SQL*Net break/reset to client時,發現一條insert語句很特殊.分析做一個記錄.
1.環境:
SYSTEM@192.168.31.8:1521/hrp430> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.3.0 Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
SELECT DISTINCT kglnaobj c120 , kglobt03 sql_id
FROM x$kglob
WHERE kglobt03 IN ( SELECT sql_id
FROM DBA_HIST_ACTIVE_SESS_HISTORY
WHERE event = 'SQL*Net break/reset to client'
GROUP BY sql_id);
C120 SQL_ID
------------------------------------------------------------------------------------------------------------------------ -------------
SELECT PBE_NAME,PBE_EDIT,PBE_TYPE,PBE_CNTR,PBE_WORK,PBE_SEQN,PBE_FLAG FROM SYSTEM.PBCATEDT ORDER BY PBE_NAME,PBE_SEQN 8gvfr81z8nfs7
Insert Into GY_XTCS ( CSMC , CSZ , MRZ , BZ ) Values ( :1 , :2 , :3 , :4 ) gftx8vhbhujf3
select count ( :"SYS_B_0" ) from yk_gnt where ypxh =:1 ddd4xgabw2tct
Select csz2 From gy_xtcs where xtxh =:"SYS_B_0" And csmc =:"SYS_B_1" c21vhszr9gbdq
SYSTEM@zzzzzz > select sql_id,sql_text,executions,rows_processed from v$sqlarea where sql_id='gftx8vhbhujf3';
SQL_ID SQL_TEXT EXECUTIONS ROWS_PROCESSED
------------- -------------------------------------------------------------------------------- ---------- --------------
gftx8vhbhujf3 Insert Into GY_XTCS ( CSMC , CSZ , MRZ , BZ ) Values ( :1 , :2 , :3 , :4 ) 13919 0
--//EXECUTIONS=13919,ROWS_PROCESSED=0,為什麼?
2.分析:
--//要分析為什麼沒有插入,要麼建立觸發器跟蹤插入語句的執行或者選擇審計表插入操作.主要是獲得繫結變數的值.
--//執行如下:
audit insert on portal_his.gy_xtcs by access whenever not successful;
select * from DBA_AUDIT_TRAIL where obj_name='GY_XTCS' and owner='PORTAL_HIS';
--//奇怪審計看不到插入的繫結變數值.如何才能看到呢?難道不成功看不到繫結變數值嗎?
3.採用跟蹤特定sql語句方式:
ALTER SYSTEM SET EVENTS 'sql_trace [sql: sql_id=gftx8vhbhujf3] bind=true, wait=true';
--//...等insert語句執行.
ALTER SYSTEM SET EVENTS 'sql_trace off';
$ cd /u01/app/oracle/diag/rdbms/hrp430/hrp430/trace
$ grep -i gftx8vhbhujf3 *.trc
hrp430_ora_12427.trc:PARSING IN CURSOR #47617027301968 len=75 dep=0 uid=94 oct=2 lid=94 tim=1542700449294504 hv=386745795 ad='aebb74d0' sqlid='gftx8vhbhujf3'
hrp430_ora_24947.trc:PARSING IN CURSOR #47018732013064 len=75 dep=0 uid=94 oct=2 lid=94 tim=1542700444830519 hv=386745795 ad='aebb74d0' sqlid='gftx8vhbhujf3'
hrp430_ora_28526.trc:PARSING IN CURSOR #47763681011784 len=75 dep=0 uid=94 oct=2 lid=94 tim=1542700476876606 hv=386745795 ad='aebb74d0' sqlid='gftx8vhbhujf3'
hrp430_ora_29024.trc:PARSING IN CURSOR #47501418697344 len=75 dep=0 uid=94 oct=2 lid=94 tim=1542700436091555 hv=386745795 ad='aebb74d0' sqlid='gftx8vhbhujf3'
$ grep -i -l gftx8vhbhujf3 *.trc | xargs -I{} sed -n '/gftx8vhbhujf3/,/=====================/p' {}
PARSING IN CURSOR #47617027301968 len=75 dep=0 uid=94 oct=2 lid=94 tim=1542700449294504 hv=386745795 ad='aebb74d0' sqlid='gftx8vhbhujf3'
Insert Into GY_XTCS ( CSMC , CSZ , MRZ , BZ ) Values ( :1 , :2 , :3 , :4 )
END OF STMT
BINDS #47617027301968:
Bind#0
oacdty=96 mxl=32(11) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=128 off=0
kxsbbbfp=2b4eb4342d48 bln=32 avl=11 flg=05
value="MS_JZGH_BLB"
Bind#1
oacdty=96 mxl=32(00) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=0 off=32
kxsbbbfp=2b4eb4342d68 bln=32 avl=00 flg=01
Bind#2
oacdty=96 mxl=32(00) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=0 off=64
kxsbbbfp=2b4eb4342d88 bln=32 avl=00 flg=01
Bind#3
oacdty=96 mxl=32(10) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=0 off=96
kxsbbbfp=2b4eb4342da8 bln=32 avl=10 flg=01
value="急診掛號費"
=====================
PARSING IN CURSOR #47018732013064 len=75 dep=0 uid=94 oct=2 lid=94 tim=1542700444830519 hv=386745795 ad='aebb74d0' sqlid='gftx8vhbhujf3'
Insert Into GY_XTCS ( CSMC , CSZ , MRZ , BZ ) Values ( :1 , :2 , :3 , :4 )
END OF STMT
BINDS #47018732013064:
Bind#0
oacdty=96 mxl=32(12) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=128 off=0
kxsbbbfp=2ac366d6a4b0 bln=32 avl=12 flg=05
value="MS_LSTD_YSDM"
Bind#1
oacdty=96 mxl=32(00) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=0 off=32
kxsbbbfp=2ac366d6a4d0 bln=32 avl=00 flg=01
Bind#2
oacdty=96 mxl=32(00) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=0 off=64
kxsbbbfp=2ac366d6a4f0 bln=32 avl=00 flg=01
Bind#3
oacdty=96 mxl=32(20) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=0 off=96
kxsbbbfp=2ac366d6a510 bln=32 avl=20 flg=01
value="綠色通道開通醫生列表"
=====================
PARSING IN CURSOR #47763681011784 len=75 dep=0 uid=94 oct=2 lid=94 tim=1542700476876606 hv=386745795 ad='aebb74d0' sqlid='gftx8vhbhujf3'
Insert Into GY_XTCS ( CSMC , CSZ , MRZ , BZ ) Values ( :1 , :2 , :3 , :4 )
END OF STMT
BINDS #47763681011784:
Bind#0
oacdty=96 mxl=32(12) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=128 off=0
kxsbbbfp=2b70d935c610 bln=32 avl=12 flg=05
value="MS_LSTD_YSDM"
Bind#1
oacdty=96 mxl=32(00) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=0 off=32
kxsbbbfp=2b70d935c630 bln=32 avl=00 flg=01
Bind#2
oacdty=96 mxl=32(00) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=0 off=64
kxsbbbfp=2b70d935c650 bln=32 avl=00 flg=01
Bind#3
oacdty=96 mxl=32(20) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=0 off=96
kxsbbbfp=2b70d935c670 bln=32 avl=20 flg=01
value="綠色通道開通醫生列表"
=====================
PARSING IN CURSOR #47501418697344 len=75 dep=0 uid=94 oct=2 lid=94 tim=1542700436091555 hv=386745795 ad='aebb74d0' sqlid='gftx8vhbhujf3'
Insert Into GY_XTCS ( CSMC , CSZ , MRZ , BZ ) Values ( :1 , :2 , :3 , :4 )
END OF STMT
BINDS #47501418697344:
Bind#0
oacdty=96 mxl=32(12) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=128 off=0
kxsbbbfp=2b33c971da48 bln=32 avl=12 flg=05
value="MS_LSTD_YSDM"
Bind#1
oacdty=96 mxl=32(00) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=0 off=32
kxsbbbfp=2b33c971da68 bln=32 avl=00 flg=01
Bind#2
oacdty=96 mxl=32(00) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=0 off=64
kxsbbbfp=2b33c971da88 bln=32 avl=00 flg=01
Bind#3
oacdty=96 mxl=32(20) mxlc=00 mal=00 scl=00 pre=00
oacflg=01 fl2=1000000 frm=01 csi=852 siz=0 off=96
kxsbbbfp=2b33c971daa8 bln=32 avl=20 flg=01
value="綠色通道開通醫生列表"
=====================
--//很明顯主鍵衝突.
SYSTEM@zzzzzz > column csz format a20
SYSTEM@zzzzzz > column MRZ format a20
SYSTEM@zzzzzz > select * from GY_XTCS where CSMC in ('MS_LSTD_YSDM','MS_JZGH_BLB');
CSMC CSZ MRZ BZ
-------------------- -------------------- -------------------- ---------------------
MS_JZGH_BLB 急診掛號費
MS_LSTD_YSDM 綠色通道開通醫生列表
--//這樣的開發團隊,真心的無語.. 欄位CSMC是主鍵.難道程式不做判斷嗎?出現ora-00001錯誤不報錯嗎?
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2220782/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SQLite Insert 語句SQLite
- insert all和insert first語句的用法
- [20230905]奇怪的語法.txt
- insert into select語句與select into from語句
- 【SQL】9 SQL INSERT INTO 語句SQL
- 教你使用SQLite-insert語句SQLite
- 【SQL】14 UNION 操作符、SELECT INTO 語句、INSERT INTO SELECT 語句、CREATE DATABASE 語句、CREATE TABLE 語句SQLDatabase
- [20181120]SQLNet break/reset to client.txtSQLclient
- 兩個看似奇怪的MySQL語句問題MySql
- SQLite語句(二):INSERT DELETE UPDATE SELECTSQLitedelete
- PostgreSQL的insert語句執行過程分析SQL
- MySQL:一個簡單insert語句的大概流程MySql
- DBeaver如何生成select,update,delete,insert語句delete
- oracle-資料庫- insert 插入語句Oracle資料庫
- [20181120]toad看真實的執行計劃.txt
- KunlunDB功能之insert/update/delete...returning語句delete
- INSERT...SELECT語句對查詢的表加鎖嗎
- [20240320]空格與sqlpus的sql語句.txtSQL
- [20200320]SQL語句優化的困惑.txtSQL優化
- Exadata混合列壓縮功能與INSERT語句BF
- 輕量ORM-SqlRepoEx (四)INSERT、UPDATE、DELETE 語句ORMSQLdelete
- [20220117]超長sql語句.txtSQL
- [20201105]再分析sql語句.txtSQL
- [20201210]sql語句優化.txtSQL優化
- [20221020]奇怪的增量備份.txt
- [20220822]奇怪的ashtop輸出.txt
- [20211111]奇怪的ashtop輸出.txt
- [20210802]grep奇怪的過濾.txt
- [20210924]awk奇怪的輸出.txt
- [20201106]奇怪的awr報表.txt
- [20211221]分析sql語句遇到的問題.txtSQL
- [20181114]一條sql語句的優化.txtSQL優化
- [20220331]如何調整sql語句.txtSQL
- [20180907]insert+with+select.txt
- 過往記憶的專欄文章轉載:Hive insert into語句用法Hive
- [20231012]奇怪的執行時長.txt
- [20230426]奇怪的AVG_IOW_MS.txt
- [20190306]奇怪的查詢結果.txt