INSERT INTO rich_customers (cust_id,cust_credit_limit) SELECT cust_id, cust_credit_limit FROM new_customers WHERE credit_limit >=100000;
INSERT INTO customers SELECT * FROM new_customers;
在Oracle9i中,upsert只要用一条语句就可以实现这个要求:
INSERT FIRST WHEN credit_limit >=100000 THEN INTO rich_customers VALUES(cust_id,cust_credit_limit) INTO customers ELSE INTO customers SELECT * FROM new_customers;