insert all\insert first

SQL> desc test;
Name Type   Nullable Default Comments
---- ------ -------- ------- --------
ID   NUMBER Y                         
N    NUMBER Y                         
 
SQL> alter table test modify n char(1);
 
Table altered
 
SQL> desc test;
Name Type    Nullable Default Comments
---- ------- -------- ------- --------
ID   NUMBER  Y                        
N    CHAR(1) Y                        
 
SQL> insert into test values(1,'a');
 
1 row inserted
 
SQL> insert into test values(2,'b');
 
1 row inserted
 
SQL> insert into test values(3,'c');
 
1 row inserted
 
SQL> insert into test values(4,'d');
 
1 row inserted
 
SQL> insert into test values(5,'f');
 
1 row inserted
 
SQL> insert into test values(6,'g');
 
1 row inserted
 
SQL> commit;
 
Commit complete
 
SQL> create table a(id number,n char(1));
 
Table created
 
SQL> create table b(id number,n char(1));
 
Table created
 
SQL> insert all into a into b select * from test;
 
12 rows inserted
 
SQL> commit;
 
Commit complete
 
SQL> select * from a;
 
        ID N
---------- -
         1 a
         2 b
         3 c
         4 d
         5 f
         6 g
 
6 rows selected
 
SQL> select * from b;
 
        ID N
---------- -
         1 a
         2 b
         3 c
         4 d
         5 f
         6 g
 
6 rows selected
 
SQL> delete from a;
 
6 rows deleted
 
SQL> delete from b;
 
6 rows deleted
 
SQL> commit;
 
Commit complete
 
SQL> insert first when id >= 3 then into a when id >=5 then into b select * from test;
 
4 rows inserted
 
SQL> select * from a;
 
        ID N
---------- -
         3 c
         4 d
         5 f
         6 g
 
SQL> select * from b;
 
        ID N
---------- -
 
SQL> rollback;
 
Rollback complete
 
SQL> insert first when id >= 5 then into a when id >=3 then into b select * from test;
 
4 rows inserted
 
SQL> select * from a;
 
        ID N
---------- -
         5 f
         6 g
 
SQL> select * from b;
 
        ID N
---------- -
         3 c
         4 d
 
SQL> rollback;
 
Rollback complete
 
SQL> insert all when id >= 3 then into a when id >=5 then into b select * from test;
 
6 rows inserted
 
SQL> select * from a;
 
        ID N
---------- -
         3 c
         4 d
         5 f
         6 g
 
SQL> select * from b;
 
        ID N
---------- -
         5 f
         6 g
 
SQL> rollback;
 
Rollback complete
 
SQL> drop table a;d
 
Table dropped
 
SQL> drop table b;
 
Table dropped
 
SQL> 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22745099/viewspace-624820/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22745099/viewspace-624820/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值