ITPub博客

首页 > Linux操作系统 > Linux操作系统 > insert all\insert first

insert all\insert first

原创 Linux操作系统 作者:CaptainKobe 时间:2010-01-11 13:41:04 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/22745099/viewspace-624820/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-01-11

  • 博文量
    23
  • 访问量
    23613