DROP_FOREIGN_TABLE(7)

โœจ 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.table is 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 EXISTS option is a PostgreSQL extension. we simply do more โœจ

๐Ÿซถ SEE ALSO ๐Ÿซถ


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 ๐ŸŒธ๐Ÿฆ‹๐Ÿ’