Rechercher dans le manuel MySQL
B.4.6.2 TEMPORARY Table Problems
Temporary tables created with
CREATE TEMPORARY
TABLE
have the following limitations:
TEMPORARY
tables are supported only by theInnoDB
,MEMORY
,MyISAM
, andMERGE
storage engines.Temporary tables are not supported for NDB Cluster.
The
SHOW TABLES
statement does not listTEMPORARY
tables.To rename
TEMPORARY
tables,RENAME TABLE
does not work. UseALTER TABLE
instead:You cannot refer to a
TEMPORARY
table more than once in the same query. For example, the following does not work:The statement produces this error:
ERROR 1137: Can't reopen table: 'temp_table'
You can work around this issue if your query permits use of a common table expression (CTE) rather than a
TEMPORARY
table. For example, this fails with the Can't reopen table error:To avoid the error, use a
WITH
clause that defines a CTE, rather than theTEMPORARY
table:The Can't reopen table error also occurs if you refer to a temporary table multiple times in a stored function under different aliases, even if the references occur in different statements within the function. It may occur for temporary tables created outside stored functions and referred to across multiple calling and callee functions.
If a
TEMPORARY
is created with the same name as an existing non-TEMPORARY
table, the non-TEMPORARY
table is hidden until theTEMPORARY
table is dropped, even if the tables use different storage engines.There are known issues in using temporary tables with replication. See Section 17.4.1.30, “Replication and Temporary Tables”, for more information.
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-temporary-table-problems.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.