如何在两列中同时添加或插入多行?

时间:2017-06-27 06:57:09

标签: oracle toad

如何在两列中同时添加或插入多行?我正在尝试这个

insert into Gwish_bal(Account_code,Flag) values (
('10192885','I'),
('10146883','I')
);

并且它无法正常工作我继续得到ORA-00907:缺少右括号。我想插入一千个数字并标记它们。我需要的输出是一个看起来像这样的表

ccount code    flag
800000008        I
800000009        I
....
800100000        I

5 个答案:

答案 0 :(得分:2)

这应该有效:

INSERT ALL
INTO Gwish_bal (Account_code, Flag) VALUES ('10192885', 'l')
INTO Gwish_bal (Account_code, Flag) VALUES ('10146883','I');

但我遇到的更常见的解决方案是:

INSERT INTO Gwish_bal(Account_code,Flag)
SELECT '10192885', 'l' FROM dual
  UNION ALL
SELECT '10146883','I' FROM dual;

答案 1 :(得分:1)

尝试

INSERT INTO Gwish_bal (Account_code, Flag)
VALUES
    ('10192885', 'l'),
    ('10146883', 'l');

答案 2 :(得分:1)

使用this语法:

INSERT ALL
  INTO Gwish_bal(Account_code,Flag) VALUES ('10192885','I')
  INTO Gwish_bal(Account_code,Flag) VALUES ('10146883','I')
SELECT * FROM dual;

千行:

insert INTO Gwish_bal(Account_code,Flag)
select to_char(level), 'I'
from dual
where level >= 10000
connect by level <= 11000 

答案 3 :(得分:1)

这应该在oracle中工作

INSERT ALL 
    INTO Gwish_bal ("Account_code", "Flag")
         VALUES ('10192885', 'l')
    INTO Gwish_bal ("Account_code", "Flag")
         VALUES ('10192885', 'l')
    INTO Gwish_bal ("Account_code", "Flag")
         VALUES  ('10192885', 'l')
 SELECT * FROM dual  ;

答案 4 :(得分:0)

您无需包装列表。

insert into Gwish_bal(Account_code,Flag) values ('10192885','I'), ('10146883','I');