ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 深入SQL之 insert all

深入SQL之 insert all

原创 Linux操作系统 作者:wmlm 时间:2008-05-09 14:03:44 0 删除 编辑
===========================================================
深入SQL之 insert all
===========================================================
用于网站数据迁移时,表之间的数据复制
INSERT ALL WHEN ottl 100000 and ottl 290000 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 c WHERE o.customer_id = c.customer_id;

Finally, the next example uses the FIRST clause to put orders greater than 2,900,000 into the special_orders table and exclude those orders from the large_orders table:

INSERT FIRST WHEN ottl 100000 and ottl 200000 THEN INTO large_orders VALUES(oid, ottl, sid, cid) 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 c WHERE o.customer_id = c.customer_id;

上面的是两个表中都插入了数据,
下面的是first插 special_orders,large_orders不再插入重复数据:p

aaa 评论于:2007.04.11 10:57
 



引文来源  王旺的书房 | 深入SQL之 insert all


Link URL: http://wworacle.blog.163.com/blog/static/21268725200849113958508

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

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

注册时间:2008-04-08

  • 博文量
    398
  • 访问量
    3716787