Insert all for multiple oracle tables (column-to-row)

Source: Internet
Author: User


Oracle multi-table insert all statement: SQL code create table ORDERS (CUSTOMER_ID NUMBER, SUM_ORDERS NUMBER); create table small_customers (CUSTOMER_ID NUMBER, SUM_ORDERS NUMBER ); create table medium_customers (CUSTOMER_ID NUMBER, SUM_ORDERS NUMBER); create table large_customers (CUSTOMER_ID NUMBER, SUM_ORDERS NUMBER); create table order_sums (CUSTOMER_ID NUMBER, SUM_ORDERS NUMBER ); SQL code insert into ORDERS (CUSTOMER_ID, SUM_ORDERS) values (1000, 10); insert into ORDERS (CUSTOMER_ID, SUM_ORDERS) values (1001, 20); insert into ORDERS (CUSTOMER_ID, SUM_ORDERS) values (1002, 30); insert into ORDERS (CUSTOMER_ID, SUM_ORDERS) values (800, 5); insert into ORDERS (CUSTOMER_ID, SUM_ORDERS) values (900, 6 ); insert into ORDERS (CUSTOMER_ID, SUM_ORDERS) values (700, 7); insert into ORDERS (CUSTOMER_ID, SUM_ORDERS) values (10000,100); insert into ORDERS (CUSTOMER_ID, SUM_ORDERS) values (20000,200); insert into ORDERS (CUSTOMER_ID, SUM_ORDERS) values (30000,300); www.2cto.com SQL code insert into ORDER_SUMS (CUSTOMER_ID, sums, MEDIUM_SUM_ORDERS, sums) values (1000, 10, 20, 30); insert into ORDER_SUMS (CUSTOMER_ID, sums, MEDIUM_SUM_ORDERS, sums) values (900, 1, 2, 3); insert into ORDER_SUMS (CUSTOMER_ID, sums, MEDIUM_SUM_ORDERS, sums) values (1, 10000,100,200,300); 1. insert to multiple tables usage SQL code insert all when customer_id <1000 then into small_customers when customer_id> = 1000 and customer_id <10000 then into medium_customers else into large_customers select customer_id, sum_orders from orders; www.2cto.com 2. insert all into small_mers MERs (mermer_id, sum_orders) values (customer_id, orders) into values (customer_id, sum_orders) values (customer_id, orders) into small_mers MERs (customer_id, orders, sum_orders) values (customer_id, large_sum_orders) select customer_id, small_sum_orders, medium_sum_orders, large_sum_orders from order_sums;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.