Oracle 多表插入语法? [英] Oracle Multi-Table Insert Syntax?

查看:27
本文介绍了Oracle 多表插入语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在第一次查看 Oracle 的多表插入(我对 SQL 整体还很陌生),我不太了解 SELECT 的目的/需要在声明结束.

I'm taking my first look at Oracle's multi-table insert (I'm fairly new to SQL overall), and I'm not quite understanding the purpose/need for the SELECT at the end of the statement.

对于单表 INSERT,我的理解是使用 VALUES 子句或子查询,但不能同时使用两者.有人能解释一下这个 INSERT 语句末尾的 SELECT 子句的意义吗?我在网上查过,但我没有找到明确的答案.

With a single-table INSERT, it's my understanding that either the VALUES clause or a subquery are used, but not both. Can someone explain the significance of the SELECT clause at the end of this INSERT statement? I've looked online, but I haven't found a clear answer.

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;

推荐答案

select 用于确定 WHEN prod_category='B' THEN 中使用的变量 prod_category 的值代码>

The select is used to determine the values of the variable prod_category used in WHEN prod_category='B' THEN

这篇关于Oracle 多表插入语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆