ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 单表分解

单表分解

原创 Linux操作系统 作者:junecaoic 时间:2008-12-09 18:55:46 0 删除 编辑
 
INSERT {all | first}
                               [when then]
                                     into [(col1,col2, ···)]
                                     [values(val1,val2, ···)]
                               [when then]
                                     into [(col1,col2, ···)]
                                     [values(val1,val2, ···)]
                               ···
                               ···
                               [when then]
                                     into [(col1,col2, ···)]
                                     [values(val1,val2, ···)]
                               [else
                                     into [(col1,col2, ···)]
                                     [values (val1,val2, ···)]
                               ]
               Subquery-definition;
 
 
SQL> Create table small_orders(order_id   number(12)   not null,
                                                              customer_id number(6) not null,
                                                              order_total   number(8,2),
                                                              sales_rep_id number(6)
                                                              );
SQL> Creat table medium_orders as select *  from small_orders;
SQL> Creat table large_orders as select *  from small_orders;
SQL>Create table  special_orders(order id number(12) not null,
                                                                 customer_id number(6),
                                                                 order_total number(8,2),
                                                                 sales_rep_id number(6),
                                                                 credit_limit number(9,2),
                                                                 cust_email   varchar2(30)
                                                                 );
 
Insert all
     when ottl < 10000 then
          into small_orders
     when ottl > 10000 and ottl < 20000 then
          into medium_orders
     when ottl> 20000 then
          into large_orders
     when ottl>29000 then
          into special_orders
      select o.order_id oid, o.customer_id cid, o.order_total ottl,
                   o.sales_rep_id sid, c.credit_limit cl, c.cust_email cem
      from orders o, customers
      where o.customer_id = c.customer_id;

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

上一篇: 多表合并
下一篇: 触发器
请登录后发表评论 登录
全部评论

注册时间:2008-12-09

  • 博文量
    14
  • 访问量
    10375