SQLite Forum

slow import of CSV files
Login
Things will go much faster if you omit all PRIMARY KEY and UNIQUE constraints
from your initial import.  You can go back afterwards and do

>   CREATE UNIQUE INDEX ...

To emulate each of your PRIMARY KEYs and UNIQUEs after the import has
finished.

Afterwards, if you want to create a new copy of the table that actually
contains a PRIMARY KEY definition, then do so, and populate the new
official table from the data in the import table using:

>   INSERT INTO official SELECT * FROM imported ORDER BY pk1, pk2, ...;

Where pk1, pk2, ... are the PRIMARY KEY columns.

All this boils down to the "in order" thing that Keith was talking about.