ORA-00933:SQL命令未在insert命令中正确结束

时间:2012-10-12 10:13:36

标签: oracle sqlfiddle

这个标题有很多问题,但我找不到答案。

我做错了什么?

CREATE TABLE J
    (A integer)
;

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

create有效。问题只是插入。我试过SQL Fiddle。

3 个答案:

答案 0 :(得分:6)

您可以采取多种方式(参见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
;

或(见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

甚至为每个语句单独INSERT语句:

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

答案 1 :(得分:1)

您正在向1列表中添加多个值。

你需要 Insert into J (A) values (1);

Insert into J (A) values (2);

答案 2 :(得分:1)

尝试:

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