I'm getting an error in SQL command not properly ended

前端 未结 5 626
梦毁少年i
梦毁少年i 2021-01-17 17:36

when I enter this

INSERT INTO works_on
(essn, pno, hours)
values
(\'123456789\', 1, 32.5),
(\'123456789\', 2, 7.5),
(\'666884444\', 3, 40.0),
(\'453453453\',         


        
5条回答
  •  伪装坚强ぢ
    2021-01-17 17:57

    You cannot combine all your values in a single insert like that in Oracle unfortunately. You can either separate your SQL statements, or use another approach like this to run in a single statement:

    INSERT INTO works_on (essn, pno, hours)
    SELECT '123456789', 1, 32.5 FROM DUAL UNION 
    SELECT '123456789', 2, 7.5 FROM DUAL UNION 
    SELECT '666884444', 3, 40.0 FROM DUAL UNION 
    SELECT '453453453', 1, 20.0 FROM DUAL UNION 
    ...
    SELECT '987987987', 30, 5.0 FROM DUAL UNION 
    SELECT '987654321', 30, 20.0 FROM DUAL UNION 
    SELECT '987654321', 20, 15.0 FROM DUAL UNION 
    SELECT '888665555', 20, 0 FROM DUAL
    

    SQL Fiddle Demo

提交回复
热议问题