DROP_FOREIGN_TABLE(7pg14)
π
DROP FOREIGN TABLE β the DROP_FOREIGN_TABLE(7) glow-up π¦
okay so this is the DROP FOREIGN TABLE(7) page from the PostgreSQL 14.24 Documentation, and bestie, it's honestly iconic β short, sweet, and it does exactly what it says on the tin. Let's get into it β¨
πΈ NAME πΈ
DROP_FOREIGN_TABLE β remove a foreign table ποΈπ
β¨ SYNOPSIS β¨
DROP FOREIGN TABLE [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
literally that's the whole thing. she's compact. she's efficient. she's giving main character energy π
π DESCRIPTION π
DROP FOREIGN TABLE removes a foreign table. that's it, that's the vibe π«Ά
and the rules? only the owner of a foreign table can remove it. no owner, no drop, periodt π
π¦ PARAMETERS π¦
IF EXISTSβ do not throw an error if the foreign table doesn't exist, bestie. instead, a notice is issued in this case. so like, no dramatic meltdown, just a little "hey, heads up" πnameβ the name of the foreign table to drop, and yeah, it can be optionally schema-qualified (iykyk). this is the thing you're yeeting ποΈCASCADEβ automatically drop objects that depend on the foreign table (such as views), and in turn all objects that depend on those objects (see Section 5.14). so like, it takes the whole friend group with it π chain reaction, no cap π₯RESTRICTβ refuse to drop the foreign table if any objects depend on it. and this one is the default, so if you don't say anything, RESTRICT is what you get. protective queen behavior honestly ππ
fr fr, know which one you're picking β CASCADE does not ask before it goes and takes the dependents with it π
π EXAMPLES π
to destroy two foreign tables, films and distributors:
DROP FOREIGN TABLE films, distributors;
two tables, one command. we love a multitasking icon β
π COMPATIBILITY π
this command conforms to ISO/IEC 9075-9 (SQL/MED) β slay β with two little caveats:
- the standard only allows one foreign table to be dropped per command (we're built different, we do multiples) πͺ
- and apart from the
IF EXISTSoption, which is a PostgreSQL extension πβ¨
π SEE ALSO π
ALTER FOREIGN TABLE(ALTER_FOREIGN_TABLE(7))CREATE FOREIGN TABLE(CREATE_FOREIGN_TABLE(7))
go read those too, they're the supporting cast and they ate π«Ά
and that's the whole page, bestie!! signed off by PostgreSQL 14.24, dated 2026 β DROP FOREIGN TABLE(7), out π
π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms