Temporary Tables
Temporary table is a table that is not stored in the database but instead exists only during the database session in which it was created.
- implement temporary tables to increase speed and also provide a form of data filter
- provide records for temporary use only
- can improve processing speeds for queries
- likely contain a smaller number of records than the permanent table
- can be created through SQL statements
- use the
CREATE TABLEsyntax to create the table - then add records to the temporarily created table using
INSERTsyntax - You would create the temporary table when querying the permanent table
- use the
- When we exit the database, the temporary tables are no longer there
Example
- we are creating a temporary table that we can then use to automatically filter addresses to only include those who are in Los Angeles
- Then we can use this table within other queries,
- without having to always use the entire address table
- the size of a database will increase over time as the number of records increases
- slow performance early on becomes even slower performance later
