插入多个值(Oracle SQL Developer)

时间:2017-12-31 19:11:03

标签: sql oracle

我试图使用多个值在语句中编写一个简单的插入。我见过的解决方案是用逗号分隔每组值,但是,我仍然遇到错误。这是我的SQL语句。

INSERT INTO DIVISION (DIVISION_ID, DIVISION_NAME)
VALUES ('20', 'Quebec'), ('30', 'Ontario');

2 个答案:

答案 0 :(得分:3)

你也可以使用这个:

INSERT ALL
  INTO DIVISION (DIVISION_ID, DIVISION_NAME) VALUES (20, 'Quebec')
  INTO DIVISION (DIVISION_ID, DIVISION_NAME) VALUES (30, 'Ontario')
SELECT * FROM dual;

答案 1 :(得分:1)

如果DIVISION_ID是数字数据类型:

INSERT INTO DIVISION (DIVISION_ID, DIVISION_NAME)
SELECT 20, 'Quebec' FROM DUAL  
UNION ALL
SELECT 30, 'Ontario' FROM DUAL;  

否则:

INSERT INTO DIVISION (DIVISION_ID, DIVISION_NAME)  
SELECT '20', 'Quebec' FROM DUAL    
UNION ALL  
SELECT '30', 'Ontario' FROM DUAL;