TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Oracle Insert All

Oracle Insert All Query for beginners and professionals with examples on insert, select, update, delete, table, view, join, key, functions, procedures, indexes, cursor etc.

<< Back to ORACLE

Oracle INSERT ALL statement

The Oracle INSERT ALL statement is used to insert multiple rows with a single INSERT statement. You can insert the rows into one table or multiple tables by using only one SQL command.

Syntax

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

Parameters

1) table_name: it specifies the table in which you want to insert your records.

2) column1, column2, column_n: this specifies the columns in the table to insert values.

3) expr1, expr2, expr_n: this specifies the values to assign to the columns in the table.

Oracle INSERT ALL Example

This example specifies how to insert multiple records in one table. Here we insert three rows into the "suppliers" table.

INSERT ALL
  INTO suppliers (supplier_id, supplier_name) VALUES (20, 'Google')
  INTO suppliers (supplier_id, supplier_name) VALUES (21, 'Microsoft')
  INTO suppliers (supplier_id, supplier_name) VALUES (22, 'Apple')
SELECT * FROM dual;

Output

3 row(s) inserted.
0.02 seconds

This is totally equivalent to the following three INSERT statements.

INSERT INTO suppliers (supplier_id, supplier_name) VALUES (1000, 'Google');
INSERT INTO suppliers (supplier_id, supplier_name) VALUES (2000, 'Microsoft');
INSERT INTO suppliers (supplier_id, supplier_name) VALUES (3000, 'Apple');

Oracle INSERT ALL Example: (Insert into multiple tables)

The INSERT ALL statement can also be used to insert multiple rows into more than one table by one command only.

In the following example, we are going to insert records into the both "suppliers" and "customers" tables.

INSERT ALL
  INTO suppliers (supplier_id, supplier_name) VALUES (30, 'Google')
  INTO suppliers (supplier_id, supplier_name) VALUES (31, 'Microsoft')
  INTO customers (age, name, address) VALUES (29, 'Luca Warsi', 'New York')
SELECT * FROM dual;

Output

3 row(s) inserted.
0.03 seconds

Here, total 3 rows are inserted, 2 rows are inserted into the suppliers table and one row into the customers table.





Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf