您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

oracle同时向多表插入数据

2024/6/9 0:08:31发布13次查看
在oracle操作过程中经常会碰到同时向多个不同的表插入数据,此时用该语句就非常合适。 all表示非短路运算,即满足了第一个条件也得向下执行查看是否满足其它条件,而first是短路运算找到合适条件就不向下进行。 insert all when prod_category=b then into b
在oracle操作过程中经常会碰到同时向多个不同的表插入数据,此时用该语句就非常合适。 all表示非短路运算,即满足了第一个条件也得向下执行查看是否满足其它条件,,而first是短路运算找到合适条件就不向下进行。 insert all
when 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; merging rows into a table
merge into oe.product_information pi
using (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);
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product