0

I'm trying to insert multiple rows into a table without specifying the column names, however, I get an error on the first comma that its a partially recognized rule and it's giving me an error

INSERT INTO MY_EMPLOYEE
VALUES(126,'Popov', 'Olga', 'opopov', 8500), 
    (127, 'Chen', 'Ling', 'lcheng', 14500), 
    (128, 'Dunn', 'David', 'ddunn', NULL);
2
  • stackoverflow.com/a/26612365/4899193 Commented Jul 15, 2017 at 18:41
  • Is this something that you need to do only once of are you writing an application that will be put into the hands of lots of people? Commented Jul 15, 2017 at 20:19

2 Answers 2

0

I don't think that Oracle supports VALUES with multiple records. Here is a simple alternative:

INSERT INTO MY_EMPLOYEE
    SELECT 126,'Popov', 'Olga', 'opopov', 8500 FROM DUAL UNION ALL
    SELECT 127, 'Chen', 'Ling', 'lcheng', 14500 FROM DUAL UNION ALL 
    SELECT 128, 'Dunn', 'David', 'ddunn', NULL FROM DUAL;

Note: I do highly recommend that you specify the columns for the insert, but that is another issue.

Sign up to request clarification or add additional context in comments.

Comments

0

Try this;

INSERT INTO MY_EMPLOYEE(col1_name,col2_name,col3_name,col4_name,col5_name)
VALUES(126,'Popov', 'Olga', 'opopov', 8500), 
    (127, 'Chen', 'Ling', 'lcheng', 14500), 
    (128, 'Dunn', 'David', 'ddunn', NULL);

1 Comment

This is MySQL syntax, the question is about Oracle that doesn't support inserting multiple rows this way.

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.