Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Adding multiple rows with a single Insert Statement

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 838
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: