Vitalii
Vitalii

Reputation: 11071

How long is temporary table available in Sqlite?

In my android app I create a temporary table to make some joins on it.

db.execSQL("CREATE TEMPORARY TABLE pair (a INTEGER, b INTEGER);")

Could you tell me for how long time it's available? It seems that if I restart app it's gone but without restart it seems to be in database but for how long time?

All I found in docs that it's created in temp database.

If the "TEMP" or "TEMPORARY" keyword occurs between the "CREATE" and "TABLE" then the new table is created in the temp database.

Upvotes: 2

Views: 1591

Answers (1)

Eugen Rieck
Eugen Rieck

Reputation: 65274

The table will be local to the SQlite session, this means it is available as long as the db object is not reinitialized.

This fits well with the idea, that temporary tables should be seen only in the context, in which they were created: Two different instances of a DB session can have temporary tables with the same name, that are completly seperate and don't influence each other.

Upvotes: 6

Related Questions