深入SQL之 insert all

wmlm發表於2008-05-09
===========================================================
深入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部落格 ” ,連結:http://blog.itpub.net/271063/viewspace-263478/,如需轉載,請註明出處,否則將追究法律責任。

相關文章