Temporary Tables

A temporary table lasts only for the current MySQL session. Therefore, after you have disconnected from the database, the table will no longer be available after you reconnect. To create a temporary table, use CREATE TEMPORARY TABLE instead of CREATE TABLE.

Temporary tables are useful if you need to manipulate data using temporary storage within an application and you do not want the tables you use to remain on the system when you are finished with them.

A temporary table name can be used simultaneously in multiple MySQL sessions. Therefore, if two instances of your program run at the same time, it is not necessary to generate a unique name for the temporary table in each instance.

Get Sams Teach Yourself MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.