ORA-00933: SQL command not properly ended in insert command

喜夏-厌秋 提交于 2019-12-20 02:11:30

问题


The are many questions with this same title but I can't find an answer among those.

What am I doing wrong?

CREATE TABLE J
    (A integer)
;

INSERT INTO J (A)
VALUES
    (1),
    (2),
    (3),
    (4),
    (5),
    (6),
    (7),
    (8),
    (9),
    (10)
;

The create alone works. The problem is just the insert. I tried in SQL Fiddle.


回答1:


You can do it several ways (See SQL Fiddle with Demo):

INSERT ALL 
    INTO J (A) VALUES (1)
    INTO J (A) VALUES (2)
    INTO J (A) VALUES (3)
    INTO J (A) VALUES (4)
    INTO J (A) VALUES (5)
    INTO J (A) VALUES (6)
    INTO J (A) VALUES (7)
    INTO J (A) VALUES (8)
SELECT * FROM dual
;

Or (See SQL Fiddle With Demo):

INSERT INTO J (A)
select  (1) from dual union all
select  (2) from dual union all
select  (3) from dual union all
select  (4) from dual union all
select  (5) from dual union all
select  (6) from dual union all
select  (7) from dual union all
select  (8) from dual union all
select  (9) from dual union all
select  (10) from dual

Or even separate INSERT statements for each one:

INSERT INTO J (A) VALUES (1);
INSERT INTO J (A) VALUES (2);
INSERT INTO J (A) VALUES (3);
INSERT INTO J (A) VALUES (4);
INSERT INTO J (A) VALUES (5);
INSERT INTO J (A) VALUES (6);



回答2:


You are adding multiple values into a 1 column table.

You need Insert into J (A) values (1);

Insert into J (A) values (2);

etc




回答3:


Try:

INSERT INTO J (A) VALUES (1);
INSERT INTO J (A) VALUES (2);
INSERT INTO J (A) VALUES (3);
INSERT INTO J (A) VALUES (4);
...
INSERT INTO J (A) VALUES (10);


来源:https://stackoverflow.com/questions/12856875/ora-00933-sql-command-not-properly-ended-in-insert-command

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!