CONCEPT Cited by 1 source
MySQL TEMPORARY keyword in DROP TABLE¶
MySQL's DROP TABLE supports a TEMPORARY keyword that
scopes the drop to a temporary table only. Postgres does
not. The absence makes a regular-table drop under the
same name a real foot-gun in Postgres.
MySQL¶
CREATE TEMPORARY TABLE snapshot (...); -- session-local
-- ... work ...
DROP TEMPORARY TABLE snapshot; -- drops only the temp, leaves any same-named regular table alone
Postgres¶
CREATE TEMPORARY TABLE snapshot (...); -- session-local
-- ... work ...
DROP TABLE snapshot; -- drops the temp if it exists; otherwise drops the regular `snapshot` table
The PlanetScale post spells out the hazard:
In Postgres, this omission requires you to be more careful with your naming convention because a temporary table may have the same name as a regular table. And since you can't specify
TEMPORARYin yourDROP TABLEstatement, you might unintentionally delete important tables.— sources/2026-04-21-planetscale-migrating-from-postgres-to-mysql
Migration implication¶
In a MySQL → Postgres migration, any code path that used
DROP TEMPORARY TABLE foo has to be audited: if a regular
foo could ever coexist in the schema, the Postgres DROP
TABLE foo will hit the wrong target. The usual fix is
naming convention — prefix temporary tables with tmp_ or
similar, or use Postgres's schema-qualified pg_temp
namespace explicitly.
In the other direction (Postgres → MySQL), the MySQL
TEMPORARY keyword becomes available as a tightening
mechanism — teams migrating in can prefer DROP TEMPORARY
TABLE over unqualified DROP TABLE once on MySQL.