a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 數據庫 > Oracle > 正文

oracle update多表關聯

2024-08-29 13:49:53
字體:
來源:轉載
供稿:網友
UPDATE A.A3 = A.A3+B.B3 的問題表A 結構 : A1 , A2 ,A3
表B 結構: B1,  B2,  B3
其中 A1 ,B1 為PK ,切值相同 就是可以使用A1 = B1 了.請問用SQL 語句或過程該如何實現如下的功能???更新A 表的 A3 ,用A.A3 與B.B3之和更新.3>update A
set A3 = (select A.A3 + B.B3 from B where A.A1 = B.B1) ;7>update (select a1,a3,b1,b3 from a,b where a1=b1) set a3=a3+b3
開執行計劃, 談論效率是沒有太多的意義的^_^..
三樓的寫法與7樓的寫法得到的結果是不同的.三樓的寫法會更新所有記錄, 而7樓的寫法只修改兩者相交的相關記錄信息.7樓的寫法可以更加輕易的控制這條update語句的執行計劃, 不過要求B表必須在對應的字段上有主鍵索引:) , 在B表在對應字段上有主鍵索引的時候, 建議使用7樓的寫法.可以參考一下這個帖子^_^http://www.cnoug.org/viewthread.php?tid=44070
(測試沒有成功..不知道怎么搞的.)
參考了下面的:
非常佩服。抱著學習的態度,重寫了一下三樓的,在沒有主鍵的情況,請指教:
update a
set a3=(select a3+b3 from b where a1=b1)
where a1=(select b1 from b where a1=b1)
如下:
update con_eme_on20050309 a set a.con_PRice=(select a.con_price+(b.annuity-a.annuity)+(b.nojob-a.nojob)+(b.medicare-a.medicare)+(b.birthfee-a.birthfee)+(b.bruisefee-a.bruisefee) from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.emp_base=(select b.emp_base from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.annuity=(select b.annuity from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.nojob=(select b.nojob from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.medicare=(select b.medicare from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.birthfee=(select b.birthfee from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.bruisefee=(select b.bruisefee from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.nojobbase=(select b.nojobbase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.mediabase=(select b.mediabase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.birthbase=(select b.birthbase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.bruisebase=(select b.bruisebase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base)
where a.emp_cod in(select b.emp_cod from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base)
公積金:
update con_eme_on20050309 a set a.con_price=(select a.con_price+(b.accumulation-a.accumulation) from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.accumulation=(select b.accumulation from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.accumulationbase=(select b.accumulationbase from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base),a.accumulationbase1=(select b.accumulationbase1 from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base)

where a.emp_cod in(select b.emp_cod from con_eme_on200404 b where a.emp_cod=b.emp_cod and a.if_act='1' and a.emp_base!=b.emp_base)


上一篇:簡便實現Oracle數據庫文件移動方法

下一篇:看看葫蘆里的藥 ORACLE性能調優原則

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 日韩精品视频在线播放 | 欧美一区免费 | 成年免费视频 | 国产成人免费视频 | 91污视频在线 | 日韩免费福利视频 | 成人午夜免费视频 | 亚洲精品www | 欧美中文在线观看 | 欧美日韩免费一区二区三区 | 国产一级在线 | 国产色网 | 特级黄一级播放 | 日本高清视频在线 | 亚洲高清在线观看 | 99热精品在线 | 超碰97人人人人人蜜桃 | 妞干网在线观看 | 亚洲毛片 | 自拍视频免费 | 亚洲激情自拍偷拍 | 在线二区| 四虎成人精品永久免费av九九 | 成人激情视频在线观看 | 久操伊人 | 青青草视频在线观看 | 国产精品美女久久久久久久久久久 | 污网站免费在线观看 | 在线中文字幕日韩 | 欧美日韩综合精品 | 日韩电影免费在线观看中文字幕 | 亚洲一区高清 | avhd101在线成人播放 | 四虎首页 | 日本不卡精品 | 妞干网免费视频 | 女人夜夜春高潮爽a∨片传媒 | 国产精品久久久久9999鸭 | 精品国模一区二区三区欧美 | 欧美一二区 | 中国特黄毛片 |