databaseoracleoracle12csqlplusdatabase-management

How to enter multiple records in single query in sql plus


I have student table with 3 atributes STUDENT_ID, NAME and AGE

I'm getting this error after executing the query Query:

INSERT INTO student(STUDENT_ID, NAME, AGE) 
values
(3, 'WILSON', 40),
(4, 'ALEX', 30);

Error: ORA-00933: SQL command not properly ended


Solution

  • You can use INSERT INTO .. SELECT and UNION ALL as follows:

    INSERT INTO student(STUDENT_ID, NAME, AGE) 
    SELECT 3, 'WILSON', 40 FROM DUAL UNION ALL
    SELECT 4, 'ALEX', 30 FROM DUAL;