在oracle操作過程中經常會遇到同時向多個不同的表插入資料,此時用該語句就非常合適。
all表示非短路運算,即滿足了第乙個條件也得向下執行檢視是否滿足其它條件,而first是短路運算找到合適條件就不向下進行。
insert allmerging rows into a tablewhen prod_category=』b』 then
into book_sales(prod_id,cust_id,qty_sold,amt_sold)
values(product_id,customer_id,sale_qty,sale_price)
when prod_category=』v』 then
into video_sales(prod_id,cust_id,qty_sold,amt_sold)
values(product_id,customer_id,sale_qty,sale_price)
when prod_category=』a』 then
into audio_sales(prod_id,cust_id,qty_sold,amt_sold)
values(product_id,customer_id,sale_qty,sale_price)
select prod_category ,product_id ,customer_id ,sale_qty
,sale_price
from sales_detail;
merge into oe.product_information piusing (select product_id, list_price, min_price
from new_prices) np
on (pi.product_id = np.product_id)
when matched then update set pi.list_price =np.list_price
,pi.min_price = np.min_price
when not matched then insert (pi.product_id,pi.category_id
,pi.list_price,pi.min_price)
values (np.product_id, 33,np.list_price, np.min_price);
oracle實現同時多表插入
oracle實現同時多表插入 最簡單的,一條select結果向多個表中插入 insert all into test1 id,name,cj into test2 id,name,cj into test3 id,name,cj select id,name,cj from test 依據條件實現 ...
oracle多表插入
發表 csdn 日期 20090828 在oracle中關於多表插入的有四種分別是 1.無條件的多表insert all 2.帶條件的多表insert all 3.帶條件的多表insert first 4 pivoting insert 語法 insert all first when condit...
oracle 多表插入
建立表 create table tb user id integer primary key,user name varchar2 20 not null,user age integer not null create sequence seq user increment by 1 start...