本文介绍了我在SQL命令中未正确结束时遇到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我输入此内容
INSERT INTO works_on
(essn, pno, hours)
values
('123456789', 1, 32.5),
('123456789', 2, 7.5),
('666884444', 3, 40.0),
('453453453', 1, 20.0),
('453453453', 2, 20.0),
('333445555', 2, 10.0),
('333445555', 3, 10.0),
('333445555', 10, 10.0),
('333445555', 20, 10.0),
('999887777', 30, 30.0),
('999887777', 10, 10.0),
('987987987', 10, 35.0),
('987987987', 30, 5.0),
('987654321', 30, 20.0),
('987654321', 20, 15.0),
('888665555', 20, 0);
我收到关注错误
ORA-00933:SQL命令未正确结束
ORA-00933: SQL command not properly ended
推荐答案
在Oracle中,您不能指定这样的多组值(我猜您来自允许该语法的MySQL背景).最简单的方法是生成多个INSERT
语句
In Oracle, you can't specify multiple sets of values like this (I'm guessing that you're coming from a MySQL background where that syntax is allowed). The simplest approach is to generate multiple INSERT
statements
INSERT INTO works_on
(essn, pno, hours)
values
('123456789', 1, 32.5);
INSERT INTO works_on
(essn, pno, hours)
values
('123456789', 2, 7.5);
INSERT INTO works_on
(essn, pno, hours)
values
('666884444', 3, 40.0);
...
您还可以使用单个INSERT ALL
语句
INSERT ALL
INTO works_on(essn, pno, hours) values('123456789', 1, 32.5)
INTO works_on(essn, pno, hours) values('123456789', 2, 7.5)
INTO works_on(essn, pno, hours) values('666884444', 3, 40.0)
INTO works_on(essn, pno, hours) values('453453453', 1, 20.0)
INTO works_on(essn, pno, hours) values('453453453', 2, 20.0)
INTO works_on(essn, pno, hours) values('333445555', 2, 10.0)
INTO works_on(essn, pno, hours) values('333445555', 3, 10.0)
...
SELECT *
FROM dual;
这篇关于我在SQL命令中未正确结束时遇到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!