DROP_FOREIGN_TABLE(7pg18)
โจ DROP FOREIGN TABLE โจ
okay bestie, we're doing PostgreSQL 18.6 Documentation today and the page is literally called DROP FOREIGN TABLE (that's DROP_FOREIGN_TABLE(7) if you're being formal ๐
). it's giving "bye bye, foreign table" energy and honestly? iconic.
๐ธ NAME ๐ธ
DROP_FOREIGN_TABLE โ remove a foreign table ๐ฆ
๐ SYNOPSIS ๐
DROP FOREIGN TABLE [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
๐ DESCRIPTION ๐
DROP FOREIGN TABLE removes a foreign table. periodt.
and the tea โ: only the owner of a foreign table can remove it. so if it's not yours, hands off, bestie ๐
โจ PARAMETERS โจ
IF EXISTSโ don't throw an error if the foreign table doesn't exist. a notice gets issued in this case, which is the polite way of being like "โฆgirl, it was never there ๐คท". no cap.nameโ the name (optionally schema-qualified) of the foreign table to drop. so like,schema.tableis totally allowed, live your life.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.15). it's the domino effect, fr fr ๐ข๐ข๐ขRESTRICTโ refuse to drop the foreign table if any objects depend on it. this is the default, so if you don't say anything, it's already being cautious for you. protective king ๐
๐ EXAMPLES ๐
to destroy two foreign tables, films and distributors:
DROP FOREIGN TABLE films, distributors;
destroy is doing a lot of heavy lifting in that sentence but okay, the docs said it, not me ๐ญ
๐ COMPATIBILITY ๐
this command conforms to ISO/IEC 9075-9 (SQL/MED), with two lil exceptions bestie:
- the standard only allows one foreign table to be dropped per command, and
- apart from that, the
IF EXISTSoption is a PostgreSQL extension. we simply do more โจ
๐ซถ SEE ALSO ๐ซถ
ALTER FOREIGN TABLE(ALTER_FOREIGN_TABLE(7))CREATE FOREIGN TABLE(CREATE_FOREIGN_TABLE(7))
and that's the whole page, no notes ๐ this was PostgreSQL 18.6, dated 2026, and yes it really is titled DROP FOREIGN TABLE(7) โ go forth and drop responsibly, bestie, and remember: RESTRICT is the default so the database is literally looking out for you ๐ธ๐ฆ๐
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms