0

I am trying to insert multiple rows into my table using the below query : INSERT INTO TABLE2(ID) VALUES(1),(2) .It is showing SQL Command Not Ended.

Is it some syntacital error?I have rechecked but still not clear what's going wrong.

  • Oracle doesn't allow that syntax. You can do separate inserts; or `insert all` but not sure that gains you much here. – Alex Poole May 28 '21 at 19:40

1 Answers1

0

Invalid syntax, of course. But, here are 3 options that work.

SQL> create table table2(id number);

Table created.

SQL>
SQL> insert into table2(id) values(1);

1 row created.

SQL> insert into table2(id) values(2);

1 row created.

SQL>
SQL> insert all
  2    into table2(id) values (1)
  3    into table2(id) values (2)
  4  select * from dual;

2 rows created.

SQL>
SQL> insert into table2(id)
  2  select 1 from dual
  3  union all
  4  select 2 from dual;

2 rows created.

SQL>
Littlefoot
  • 131,892
  • 15
  • 35
  • 57