1704
MySQLERRORNotableInnoDBHIGH confidence
Cannot DISCARD or IMPORT tablespace for a temporary table
Production Risk
Low — operation rejected; temporary table is unaffected.
What this means
ALTER TABLE ... DISCARD TABLESPACE or ALTER TABLE ... IMPORT TABLESPACE is not supported for temporary tables.
Why it happens
- 1Attempting DISCARD/IMPORT TABLESPACE on a table created with CREATE TEMPORARY TABLE.
How to reproduce
trigger — this will error
trigger — this will error
CREATE TEMPORARY TABLE tmp (id INT); ALTER TABLE tmp DISCARD TABLESPACE;
expected output
ERROR 1704 (HY000): Cannot DISCARD/IMPORT tablespace associated with temporary table.
Fix
Use regular (non-temporary) tables for tablespace operations
Use regular (non-temporary) tables for tablespace operations
CREATE TABLE tmp_perm (id INT); ALTER TABLE tmp_perm DISCARD TABLESPACE;
Why this works
Tablespace import/export is only valid for persistent InnoDB tables.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 1704 ER_CANNOT_DISCARD_TEMPORARY_TABLE
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev