SQLite Insert Multiple Records into table

前端之家收集整理的这篇文章主要介绍了SQLite Insert Multiple Records into table前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

The sqlite does not support below insert sql statement:

INERT INTO table(col1,col2,...,coln) VALUES (1v1,1v2,1vn),(2v1,2v2,2vn),(3v1,3v2,3vn),(nv1,nv2,nvn);



This is the solution:

INSERT INTO table(col1,coln)

SELECT1v1,1vn UNION ALL SELECT2v1,2vnUNION ALL SELECT3v1,3vn ...UNION ALL SELECTnv1,nvn;



Recently,I handled a project that every 50 millisecondor 20 millisecond the main process would receive a message to insert a record into DB.

It is strange that the DB function was called successfully,but the messages of main process were blocked,which lead the main window blocked.

It took me much time to find the reason. but i got nothing.

Then I thought maybe something was being blocked in sqlite Lib,when "insert operating" so frequently executed.


Why not insert multiple records into the DB one time??


So,I write a thread to handle it. insert records to DB every 5 second.

猜你在找的Sqlite相关文章