I donĀ“t know why SQL Developer returned “SQL command not properly ended” when i tried to add multiple rows. When i tried to insert one row, all was ok. Can somebody help me? Thanks.
INSERT INTO TEAMS (TEAM_ID, NAME, POSITION, PLAYED, WIN, LOSE, DRAW, GF, GA, GD, POINTS) VALUES ('MUN','MANCHESTER UNITED', 2, 29, 16, 9, 4, 56, 32, 24, 57), ('LEI','LEICESTER CITY', 3, 29, 17, 5, 7, 53, 32, 21, 56), ('CHE','CHELSEA', 4, 29, 14, 9, 6, 44, 25, 19, 51); ```
Advertisement
Answer
Oracle require separate insert statements. VALUES
can only be used for a single row. Alternatively, you can use INSERT . . . SELECT
:
INSERT INTO TEAMS (TEAM_ID, NAME, POSITION, PLAYED, WIN, LOSE, DRAW, GF, GA, GD, POINTS) SELECT 'MUN','MANCHESTER UNITED', 2, 29, 16, 9, 4, 56, 32, 24, 57 FROM DUAL UNION ALL SELECT 'LEI','LEICESTER CITY', 3, 29, 17, 5, 7, 53, 32, 21, 56 FROM DUAL UNION ALL SELECT 'CHE','CHELSEA', 4, 29, 14, 9, 6, 44, 25, 19, 51 FROM DUAL;