DROP_FOREIGN_TABLE(7pg16)
π DROP FOREIGN TABLE β the pg16 glow-up π¦
okay bestie so you've got a foreign table and you want it gone β like, gone gone. This is the PostgreSQL 16.15 documentation for DROP FOREIGN TABLE and I'm gonna walk you through it, no cap. β¨
πΈ NAME πΈ
DROP_FOREIGN_TABLE β remove a foreign table. literally just yeet it. π
π SYNOPSIS π
DROP FOREIGN TABLE [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
that's the whole vibe. very demure, very mindful. π«Ά
β¨ DESCRIPTION β¨
DROP FOREIGN TABLE removes a foreign table. that's the main character move. but bestie, listen β only the owner of a foreign table can remove it. so if it's not yours, hands off. π
π PARAMETERS π
IF EXISTSβ don't throw an error if the foreign table doesn't exist. instead a notice gets issued in this case. like, "hey, it wasn't there anyway, we're fine." πnameβ the name of the foreign table to drop. it can be optionally schema-qualified, so you can be all fancy and specific about it. π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). yes, it cascades. yes, that's a lot of dropping. you've been warned. π₯RESTRICTβ refuse to drop the foreign table if any objects depend on it. this one is the default, so if you don't say anything it's gonna be cautious. π
π EXAMPLES π
to destroy two foreign tables, films and distributors:
DROP FOREIGN TABLE films, distributors;
two at once. we love efficiency. π
π§ COMPATIBILITY π§
this command conforms to ISO/IEC 9075-9 (SQL/MED), except that the standard only allows one foreign table to be dropped per command, and apart from the IF EXISTS option, which is a PostgreSQL extension. so like... mostly standard, a little bit extra. iconic behavior. β
π¦ SEE ALSO π¦
ALTER FOREIGN TABLE(ALTER_FOREIGN_TABLE(7))CREATE FOREIGN TABLE(CREATE_FOREIGN_TABLE(7))
PostgreSQL 16.15 Β· 2026 Β· DROP FOREIGN TABLE(7)
that's the page bestie, mwah. ππβ¨ go forth and drop responsibly. π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-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