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

后端 未结 24 2952
猫巷女王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条回答
  •  Happy的楠姐
    2020-11-21 06:46

    The problem with using transaction is that you lock the table also for reading. So if you have really much data to insert and you need to access to your data, for exemple a preview or so, this way doesn't work well.

    The problem with the other solution is that you lose the order of the inserting

    insert into mytable (col)
    select 'c'
    union 
    select 'd'
    union 
    select 'a'
    union 
    select 'b';
    

    In the sqlite the data will be store a,b,c,d...

提交回复
热议问题