3

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?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user2602807
  • 1,232
  • 2
  • 15
  • 28

1 Answers1

1

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.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • @a_horse_with_no_name . . . That is actually funny in the context of this query and my answer. Although escaping isn't necessary, I put in double quotes because that is standard. – Gordon Linoff Feb 03 '14 at 15:16