Home > Database > Mysql Tutorial > body text

oracle同时向多表插入数据

WBOY
Release: 2016-06-07 16:20:18
Original
1453 people have browsed it

在Oracle操作过程中经常会碰到同时向多个不同的表插入数据,此时用该语句就非常合适。 All表示非短路运算,即满足了第一个条件也得向下执行查看是否满足其它条件,而First是短路运算找到合适条件就不向下进行。 INSERT ALL WHEN prod_category=B THEN INTO b

oracle同时向多表插入数据

  在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

oracle同时向多表插入数据

  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);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template