oracleinsertall復(fù)合表插入

insert all (復(fù)合表插入),是將一個(gè)查詢結(jié)果同時(shí)插入多個(gè)表中的功能。使用insert all的好處是通過讀取一次源表就可以插入多張目標(biāo)表,減少重復(fù)讀取的開銷。

成都創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站制作、成都做網(wǎng)站、外貿(mào)營(yíng)銷網(wǎng)站建設(shè)、克拉瑪依區(qū)網(wǎng)絡(luò)推廣、重慶小程序開發(fā)、克拉瑪依區(qū)網(wǎng)絡(luò)營(yíng)銷、克拉瑪依區(qū)企業(yè)策劃、克拉瑪依區(qū)品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);成都創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供克拉瑪依區(qū)建站搭建服務(wù),24小時(shí)服務(wù)熱線:13518219792,官方網(wǎng)址:bm7419.com

語法:

INSERT [ALL] [conditional_insert_clause]

[insert_into_clause value_clause] (subquery);

conditional_insert_clause is:

[ALL] [FIRST]

[WHEN condition THEN] [insert_into_clause value_clause]

[ELSE] [insert_into_clause value_clause]

all:不考慮先后關(guān)系,只要滿足條件,就全部插入; 
first:考慮先后關(guān)系,如果有數(shù)據(jù)滿足第一個(gè)when條件又滿足第二個(gè)when條件,則執(zhí)行第一個(gè)then插入語句,第二個(gè)then就不插入第一個(gè)then已經(jīng)插入過的數(shù)據(jù)了。 
其區(qū)別也可描述為,all只要滿足條件,可能會(huì)作重復(fù)插入;first首先要滿足條件,然后篩選,不做重復(fù)插入 

示例:

insert all 
   when c1<1000 then into samall_orders values (oid,c1,sid,cid)
   when c1 <2000 then into medium_orders values (oid,c1,sid,cid)
   when c1>2000 and c1 <2900 then into large_orders vlaues (oid,c1,sid,cid)
   else into special_orders
   select oid,c1,sid,cid  
   from orders;

     指定insert first 當(dāng)?shù)谝粋€(gè)when條件成立時(shí),執(zhí)行該when條件后的語句,并且跳過后面的 WHEN 子句(后面的when語句都不再考慮滿足第一個(gè)When子句的記錄,即使該記錄滿足when語句中的條件)。

insert first
   when c1<1000 then into samall_orders values (oid,c1,sid,cid)
   when c1 <2000 then into medium_orders values (oid,c1,sid,cid)
   when c1>2000 and c1 <2900 then into large_orders vlaues (oid,c1,sid,cid)
   else into special_orders
   select oid,c1,sid,cid  
   from orders;

    上面兩條語句區(qū)別在第二個(gè)when條件,insert all 中 第二個(gè)條件會(huì)插入orders 表中c1<2000的記錄,insert first 中第二個(gè)when條件會(huì)插入orders表中1000<c1<2000的記錄,insert first中插入第二個(gè)when子句中的表時(shí)排除了第一個(gè)when條件的記錄,

當(dāng)前題目:oracleinsertall復(fù)合表插入
標(biāo)題來源:http://bm7419.com/article30/jdcsso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、網(wǎng)站維護(hù)商城網(wǎng)站、移動(dòng)網(wǎng)站建設(shè)微信公眾號(hào)、企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作