0

Example: INSERT INTO TABLE ( USERID, USERNAME) VALUES (1,"ok1"),(2,"ok2");

As i understood ,Multiple rows insertion not allowed in Oracle Database.

Please confirm me if any other alternatives for inserting multiple records into oracle DB with above format.

1 Answer 1

2

Oracle only allows one row to be inserted at a time. So use two inserts:

INSERT INTO TABLE ( USERID, USERNAME)
    VALUES (1, 'ok1');

INSERT INTO TABLE ( USERID, USERNAME)
    VALUES (2, 'ok2');

Or use INSERT . . . SELECT:

INSERT INTO TABLE ( USERID, USERNAME)
    SELECT 1 'ok1' FROM DUAL UNION ALL
    SELECT 2, 'ok2' FROM DUAL;
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks . Yes - the above option is working . i have already tested . But looking for if any other option.
If you need load a lot of records from a flat file, sql loader is a good option. External tables is another option
One disadvantage with this is we cant use a sequnce.nextval as it is prohibited in union of select
@GordonLinoff can you tell me why your second method is not working? dbfiddle.uk/sB1BGlXQ

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.