top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the use of INSERT ALL in SQL/Oracle?

+2 votes
420 views
What is the use of INSERT ALL in SQL/Oracle?
posted Jul 27, 2015 by Suchithra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

INSERT ALL is used to insert multiple rows into a single table or different tables in a signle SQL statement.

SYNTAX

INSERT ALL
  INTO mytable (column1, column2, column_n) VALUES (expr1, expr2, expr_n)
  INTO mytable (column1, column2, column_n) VALUES (expr1, expr2, expr_n)
  INTO mytable (column1, column2, column_n) VALUES (expr1, expr2, expr_n)
SELECT * FROM dual;

mytable:                       The table to insert the records into.
column1, column2, column_n:    The columns in the table to insert values.
expr1, expr2, ... expr_n:      The values to assign to the columns in the table.

Example

INSERT ALL
INTO suppliers (supplier_id, supplier_name) VALUES (1000, 'QueryHome')
INTO suppliers (supplier_id, supplier_name) VALUES (2000, 'ABC')
INTO customers (customer_id, customer_name, city) VALUES (999, 'XYZ Construction', 'New Delhi')
SELECT * FROM dual;
answer Jul 27, 2015 by Salil Agrawal
...