INSERT ALL Statement:
With the help of INSERT ALL statement we can add multiple rows with a single INSERT statement. We can use this statement to insert multiple rows in one or more than one tables. It eliminates the need of writing insert statement multiple times.
Syntax:
INSERT ALL
INTO tablename (column1, column2, ....,columnN) VALUES (expr1, expr2, exprN)
INTO tablename (column1, column2, ....,columnN) VALUES (expr1, expr2, exprN)
INTO tablename (column1, column2, ....,columnN) VALUES (expr1, expr2, exprN)
SELECT * FROM dual;
Example to add multiple rows in a single table:
INSERT ALL
INTO Employee (EMPid, EMPname) VALUES (100, 'John')
INTO Employee (EMPid, EMPname) VALUES (101, 'Mickey')
INTO Employee (EMPid, EMPname) VALUES (102, 'Stephan')
SELECT * FROM dual;
The above query will insert 3 rows in Employee table.
Example to add multiple rows in multiple table:
INSERT ALL
INTO Employee (Employee_id, Employee_name) VALUES (1001, 'Sam')
INTO Employee (Employee_id, Employee_name) VALUES (1002, 'Max')
INTO Clients (Clients_id, Clients_name) VALUES (1011, 'Google')
SELECT * FROM dual;
The above query will add 2 rows in Employee table and one row in Clients table.
0 Comment(s)