Is it possible to insert multiple rows at a time in an SQLite database?

后端 未结 24 2877
猫巷女王i
猫巷女王i 2020-11-21 06:12

In MySQL you can insert multiple rows like this:

INSERT INTO \'tablename\' (\'column1\', \'column2\') VALUES
    (\'data1\', \'data2\'),
    (\'data1\', \'da         


        
24条回答
  •  终归单人心
    2020-11-21 06:52

    According to this page it is not supported:

    • 2007-12-03 : Multi-row INSERT a.k.a. compound INSERT not supported.
      INSERT INTO table (col1, col2) VALUES 
          ('row1col1', 'row1col2'), ('row2col1', 'row2col2'), ...
    

    Actually, according to the SQL92 standard, a VALUES expression should be able to stand on itself. For example, the following should return a one-column table with three rows: VALUES 'john', 'mary', 'paul';

    As of version 3.7.11 SQLite does support multi-row-insert. Richard Hipp comments:

    "The new multi-valued insert is merely syntactic suger (sic) for the compound insert. There is no performance advantage one way or the other."

提交回复
热议问题