Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which databases support BATCH INSERT syntax?

I know, MySQL supports BATCH INSERT syntax like:

INSERT INTO `table_1` values(1, 2, 3), (3, 4, 5), (5, 6, 7);

Is this syntax included in SQL-92 format? If not, witch data bases support this syntax?

like image 514
user2602807 Avatar asked Dec 06 '25 10:12

user2602807


1 Answers

If you are concerned about portability, many databases support:

INSERT INTO "table_1"
    select 1, 2, 3 union all
    select 3, 4, 5 union all
    select 5, 6, 7;

(Offhand, SQL Server, Postgres, MySQL, Teradata.)

And most of the rest support:

INSERT INTO "table_1"
    select 1, 2, 3 from dual union all
    select 3, 4, 5 from dual union all
    select 5, 6, 7 from dual;

(Offhand, Oracle, MySQL)

Access and DB2 (offhand) don't support either of these syntaxes.

like image 162
Gordon Linoff Avatar answered Dec 08 '25 02:12

Gordon Linoff