In MySQL you can insert multiple rows like this:
INSERT INTO 'tablename' ('column1', 'column2') VALUES
('data1', 'data2'),
('data1', 'data2'),
('data1', 'data2'),
('data1', 'data2');
However, I am getting an error when I try to do something like this. Is it possible to insert multiple rows at a time in an SQLite database? What is the syntax to do that?
According to this page it is not supported:
As of version 3.7.11 SQLite does support multi-row-insert. Richard Hipp comments:
in mysql lite you cannot insert multiple values, but you can save time by opening connection only one time and then doing all insertions and then closing connection. It saves a lot of time
you can use InsertHelper, it is easy and fast
documentation: http://developer.android.com/reference/android/database/DatabaseUtils.InsertHelper.html
tutorial: http://www.outofwhatbox.com/blog/2010/12/android-using-databaseutils-inserthelper-for-faster-insertions-into-sqlite-database/
Edit: InsertHelper is deprecated as of API Level 17
As the other posters have said, SQLite does not support this syntax. I don't know if compound INSERTs are part of the SQL standard, but in my experience they're not implemented in many products.
As an aside, you should be aware that INSERT performance in SQLite is improved considerably if you wrap multiple INSERTs in an explicit transaction.
Start from version 2012-03-20 (3.7.11), sqlite support the following INSERT syntax:
Read documentation: http://www.sqlite.org/lang_insert.html
PS: Please +1 to Brian Campbell's reply/answer. not mine! He presented the solution first.