如何使用一个insert语句将多行插入oracle数据库? [重复]

时间:2021-08-26 10:26:20

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

可能重复:在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

我收到此错误ORA-00933:SQL命令未正确结束

1 个解决方案

#1


17  

you are using oracle, try this

你正在使用oracle,试试这个

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');

#1


17  

you are using oracle, try this

你正在使用oracle,试试这个

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');