How can I insert multiple row into oracle database using one insert statement?

Moataz Aahmed Mohammed picture Moataz Aahmed Mohammed · Jan 21, 2013 · Viewed 78k times · Source

Possible Duplicate:
Best way to do multi-row insert in Oracle?

I have this insert statement

INSERT INTO mytable VALUES 
('val1', 'val2'),
('aa',   'cc'),
('ww',   'dd');

and I got this error ORA-00933: SQL command not properly ended

Answer

John Woo picture John Woo · Jan 21, 2013

you are using oracle, try this

INSERT ALL 
    INTO mytable ("id", "name")
         VALUES ('val1', 'val2')
    INTO mytable ("id", "name")
         VALUES ('aa', 'cc')
    INTO mytable ("id", "name")
         VALUES  ('ww', 'dd')
SELECT * FROM dual  ;

or simple

INSERT INTO mytable ("id", "name") VALUES ('val1', 'val2');
INSERT INTO mytable ("id", "name") VALUES ('aa', 'cc');
INSERT INTO mytable ("id", "name") VALUES ('ww', 'dd');