By default, sqlite3 will use a file to store temporary tables and indices. It does this by referencing the SQLITE_TEMP_STORE preprocessor macro. As long as SQLITE_TEMP_STORE can be overridden, running PRAGMA temp_store=MEMORY; will tell sqlite3 to store these temporary tables and indices in memory instead of a file.

$ sqlite3

sqlite> PRAGMA temp_store;  

sqlite> PRAGMA temp_store = MEMORY;

sqlite> PRAGMA temp_store;  

Note that any existing temporary tables will be deleted as soon as the pragma setting is modified.