隨筆 - 6  文章 - 129  trackbacks - 0
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(14)

          隨筆檔案(6)

          文章分類(467)

          文章檔案(423)

          相冊

          收藏夾(18)

          JAVA

          搜索

          •  

          積分與排名

          • 積分 - 827240
          • 排名 - 49

          最新評論

          閱讀排行榜

          評論排行榜

          從oracle9i開始引入了insert all關鍵字支持將某張表的數據同時插入多張表單。語法如下:
          Insert all Insert_into_clause [value_clause] subquery;
          Insert conditional_insert_clause subquery;
          如上所示,insert_into_clause用于指定insert子句;value clause用于指定值子句;subquery用于指定提供數據的子查詢;condition_insert_clause用于指定insert條件子句。
          當使用all操作符執行多表插入時,在每個條件子句上都要執行into子句后的子查詢,并且條件中使用的列必須在插入和子查詢的結果集中:

          --使用all關鍵字執行多表插入操作
          insertall
          when birthday > '01-1-08'theninto tdate1
          when birthday < '01-1-08'theninto tdate2
          whenname = 'zhangsan'theninto tdate1
          whenname = 'lisi'theninto tdate2
          select * from tdate;
          在上述操作語句中,如果原表tdate中存在既滿足birthday > '01-1-08'又滿足name = 'zhangsan'的數據,那么將執行兩次插入。而使用first關鍵字就可以避免這個問題。使用first關鍵字時,如果有記錄已經滿足先前條件,并且已經被插入到某個表單中(未必非要是同一個表),那么該行數據在后續插入中將不會被再次使用。也就是說使用first關鍵字,原表每行數據按照執行順序只會被插入一次。
          insertfirst
          when birthday > '01-1-08'theninto tdate1
          when birthday < '01-1-08'theninto tdate2
          whenname = 'zhangsan'theninto tdate1
          whenname = 'lisi'theninto tdate2
          select * from tdate;


          posted on 2009-09-12 09:24 Ke 閱讀(908) 評論(0)  編輯  收藏 所屬分類: oracle
          主站蜘蛛池模板: 嵩明县| 普洱| 盐亭县| 广安市| 屏边| 神农架林区| 盐津县| 饶平县| 天津市| 镇沅| 遂平县| 永定县| 莲花县| 江孜县| 高雄县| 许昌市| 林州市| 平舆县| 枣阳市| 凤凰县| 安义县| 淮北市| 神池县| 枣强县| 泾源县| 深水埗区| 莎车县| 济阳县| 化隆| 福建省| 集贤县| 芒康县| 大庆市| 商丘市| 密山市| 饶河县| 宜春市| 古田县| 卫辉市| 秭归县| 栖霞市|