insert all

SQL> create table t1 as select * fromemp;

Table created.

 

SQL> create table t2 as select * fromemp;

Table created.


SQL> insert all into t1 select * fromemp;

14 rows created.

 

SQL> insert all when sal>2000 theninto t1 when sal<2000 then into t2 select * from emp;

14 rows created.


Insert all ----不带条件

SQL> insert all intoa2(no,sub_no,repay,period)

 2  values(no,sub_no,repay,period)

 3  into a3(no,sub_no,period)

 4  values(no,'1234',period)

 5  select * from a1;

16 rows created.


Insert all ----带条件

SQL> insert all 

 2  when period=0 then  

 3  into a2(no,sub_no,repay,period) 

 4 values(no,sub_no,repay,period) 

 5  else 

 6  intoa3(no,sub_no,repay,period) 

 7 values(no,sub_no,repay,period) 

 8  select no,sub_no,repay,periodfrom a1; 

8 rows created.


---insert first

SQL> insert first

  2  when period=0 then

 3  into a2(no,sub_no,repay,period)

 4  values(no,sub_no,repay,period)

 5  when sub_no='2104' then

 6  into a3(no,sub_no,repay,period)

 7  values(no,sub_no,repay,period)

 8  select no,sub_no,repay,periodfrom a1;

8 rows created.

 

Insert all和insert first的关系
All:不考虑先后关系,只要满足条件,就全部插入
First:考虑先后关系,如果有数据满足第一个条件又满足第二个条件,则执行第一个then插入语句,第二个then就不插入。
也可描述为:all只要满足条件,可能会做重复插入;first首先要满足条件,然后筛选,不做重复插入

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值