国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > Oracle > 正文

關(guān)于ORACLE的UPDATE更新多表的問題

2024-08-29 13:54:04
字體:
供稿:網(wǎng)友
關(guān)于Oracle的UPDATE更新多表的問題
有以下幾種方式可以實現(xiàn):
一種是:
   update table1
      set (field1,field2...) =
          (Select Field1,field2....
             from table2
            where table1.field1=table2.field1)
    where table1.field1 in (select field1 from table2)

二種是:
   將table1,table2相關(guān)聯(lián)字段建立主鍵PRimary key 或Union key
   Update (Select Table1.field1,table1.field2,table2.field1,table2.field2
             from table1,table2
            where Table1.Field1=table2.field1)

      Set table1.table2=table2.table2,
          table1.fieldn=table2.tablen,
          ......
   table1的Field1和table2的field1將需要建立主鍵或唯一索引才行

三種是:
merge into table1
using table2
     on (table1.field1=table2.field1 and ....)
   when matched then Update set table1.field2=table2.field2,
                                table1.fieldn=table2.fieldn,
                                ......
when not matched then [doing other thing]

其余方法可使用游標



本文來自CSDN博客,轉(zhuǎn)載請標明出處:http://blog.csdn.net/cgboy88/archive/2009/12/30/5105594.aspx
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 嘉善县| 象山县| 东丰县| 深水埗区| 怀来县| 英德市| 吕梁市| 沿河| 平江县| 奇台县| 阿城市| 咸宁市| 新和县| 吉木乃县| 宁城县| 永清县| 长阳| 鹤庆县| 鄂州市| 四平市| 玉溪市| 郸城县| 崇礼县| 通化县| 珠海市| 永昌县| 新闻| 英吉沙县| 新竹县| 且末县| 綦江县| 施甸县| 普宁市| 林州市| 洛宁县| 大连市| 汕尾市| 共和县| 右玉县| 荔浦县| 资溪县|