3

有很多同名的问题,但我在其中找不到答案。

我究竟做错了什么?

CREATE TABLE J
    (A integer)
;

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

create独自工作。问题只是插入。我在 SQL Fiddle 中尝试过。

4

3 回答 3

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);
于 2012-10-12T10:18:06.973 回答
1

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

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

Insert into J (A) values (2);

ETC

于 2012-10-12T10:18:46.617 回答
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);
于 2012-10-12T10:19:16.343 回答