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

后端 未结 24 2868
猫巷女王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:41

    I wrote some ruby code to generate a single 500 element multi-row insert from a series of insert statements which was considerably faster than running the individual inserts. Then I tried simply wrapping the multiple inserts into a single transaction and found that I could get the same kind of speed up with considerably less code.

    BEGIN TRANSACTION;
    INSERT INTO table VALUES (1,1,1,1);
    INSERT INTO table VALUES (2,2,2,2);
    ...
    COMMIT;
    

提交回复
热议问题