我试图使用多个值在语句中编写一个简单的插入。我见过的解决方案是用逗号分隔每组值,但是,我仍然遇到错误。这是我的SQL语句。
INSERT INTO DIVISION (DIVISION_ID, DIVISION_NAME)
VALUES ('20', 'Quebec'), ('30', 'Ontario');
答案 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;