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

1 Answer

0 votes
by (11.3k 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.