title: Use of temp tables in SQLite databases
body: <p>I was browsing through the source code for <a href="http://code.google.com/p/mendeley-for-android/" rel="nofollow noreferrer">Mendeley for Android</a> by Martin Eve and saw that Temp tables are created along with the main tables by calling replace on the tables with _id. For example on the Collections table </p>
  
  <pre><code>db.execSQL(COLLECTIONS_CREATE.replace(" (_id", "_TEMP (_id"));
  </code></pre>
  
  <p>I guess it creates a new temporary table. Any more explanation on this would be great. Further on the data is first inserted to temp tables and later moved to main tables. </p>
  
  <p>I searched through SO and came across <a href="https://stackoverflow.com/questions/4976585/what-are-the-use-cases-for-temporary-tables-in-sql-database-systems">What are the use cases for temporary tables in SQL database systems?</a> and saw that temp tables are used for handling complex queries, sorting and for increasing performance. Can anyone explain how it helps in this situation?</p>