Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6142403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:22:53+00:00 2026-05-23T18:22:53+00:00

I was browsing through the source code for Mendeley for Android by Martin Eve

  • 0

I was browsing through the source code for Mendeley for Android 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

db.execSQL(COLLECTIONS_CREATE.replace(" (_id", "_TEMP (_id"));

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.

I searched through SO and came across What are the use cases for temporary tables in SQL database systems? 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:22:54+00:00Added an answer on May 23, 2026 at 6:22 pm

    Temp tables make things easier for the programmer by letting the programmer break up a single complex query into multiple relatively simpler queries, and also by letting the programmer store results temporarily so they can be consulted multiple times for different purposes during the course of the program without having to be reinstantiated each time. The latter also makes things easier for the computer. The disk subsystem and CPU can take a little rest, so to speak.

    An example of the former: let say you wanted to get all records where:

                        the sale was in the eastern division
                        and involved one of the several new gizmos introduced last quarter
                        and occurred during the special 5-day bonanza sale
    
                        or
    
                        the sale was made by the boss's daughter
                        who floats from division to division
                        and the sale occurred at any time during the month of May
    

    Your program will then generate an email praising the salesperson for the sale, with a cc to the division manager.

    The single query that fetches records that satisfy either of those sets of conditions above might get a little unwieldy–just a little difficult for one’s addled brain or weary eyes to handle after a long day of dealing with the sort of crap one has to deal with in most walks of life. It’s a trivial example, of course; in a production system the conditions are often more complex than those above, involving calculations and tests for null values and all sorts of other tedious things that can cause a query statement to grow long and turn into a ball of tangled yarn.

    So if you created a temp table, you could populate the temp table with the rows that satisfy the first set of conditions, and then write the second query that grabs the rows that satisfy the second set of conditions, and insert them into the temp table too, and voilà — your temp table contains all the rows you need to work with, in two baby steps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Browsing through the source code of Microsoft's sample StockTrader application, I found this snippet
I was browsing through the code of Vosao CMS , an open source CMS
While browsing through the source code of the java.util.concurrency package, I noticed an idiomatic
Hi all I was browsing through some of the Java source code when I
While browsing through source code in my IDE I'll sometimes wish I could see
I was browsing through the ICU source code ( http://icu-project.org/ ), and I couldn't
I'm browsing through OpenJDK sources and cannot find the place where optimized code is
Browsing through Guava libraries I saw this weird signature on the readLines method of
Browsing through some C++ questions I have often seen comments that a STL-friendly class
I was browsing through one site called BSEINDIA.com ( http://www.bseindia.com/stockreach/stockreach.htm?scripcd=532667 ), i Noticed that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.