Is it possible to create a temporary (session only) table from a select statement without using a create table statement and specifying each column type? I know derived tables are capable of this, but those are super-temporary (statement-only) and I want to re-use.
It would save time if I did not have to write up a create table command and keep the column list and type list matched up.
Use this syntax:
Engine must be before select:
In addition to psparrow's answer if you need to add an index to your temporary table do:
It also works with
PRIMARY KEY
From the manual found at http://dev.mysql.com/doc/refman/5.7/en/create-table.html
ENGINE=MEMORY
is not supported when table containsBLOB
/TEXT
columns