+3 votes
in Databases by (15.9k points)
retagged by
How can I create temporary table so that it gets deleted itself once session is closed?

1 Answer

0 votes
by (15.9k points)

The syntax for 'create table' in mysql is as follows...

CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name xxxxxxxxxxxxxxxx

 xxxxxxxxxxxxxxxx represents other options.

So, to create temporary table, use keyword TEMPORARY. Such table will be visible only in your current database session and it will be automatically deleted when your connection is closed.