DROP_FOREIGN_TABLE(7pg17)

πŸ“¦ version 17.11, in opensuse-leap 16.0

✨ DROP FOREIGN TABLE πŸ’…

okay bestie so this is the DROP FOREIGN TABLE page from the PostgreSQL 17.11 docs β€” yes, the big PostgreSQL manual, and yes we're gonna get through it together. iykyk 🫢


🌸 SYNOPSIS 🌸

DROP FOREIGN TABLE [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]

that's the whole vibe. one command, some optional bits, slay. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

So. DROP FOREIGN TABLE removes a foreign table. That's it, that's the whole thing. πŸ’€

But listen β€” only the owner of a foreign table can remove it. not your friend, not your cousin, not the random person in the group chat who swears they have admin. the owner. periodt. πŸ‘‘


πŸ¦‹ PARAMETERS πŸ¦‹

  • IF EXISTS β€” do not throw an error if the foreign table doesn't exist. instead, a notice gets issued. so it's like "bestie i looked and it's not there πŸ₯Ί" instead of a full-on crash-out. πŸ™ˆ
  • name β€” the name of the foreign table you wanna drop. and it can be optionally schema-qualified, so you can be all precise about it. 🎯
  • CASCADE β€” this one's spicy πŸ”₯: automatically drop objects that depend on the foreign table (things like views), and then in turn all the objects that depend on those objects. it's giving domino effect. see Section 5.15 for the full lore.
  • RESTRICT β€” refuse to drop the foreign table if any objects depend on it. this is the default, so if you don't say anything, this is what you get. no surprise deletions, we're being responsible. 🌸

✨ EXAMPLES ✨

wanna destroy two whole foreign tables, films and distributors? iconic. here's the line:

DROP FOREIGN TABLE films, distributors;

gone. poof. 🧚 two of them, one command. main character energy honestly.


πŸ’œ COMPATIBILITY πŸ’œ

So this command conforms to ISO/IEC 9075-9 (SQL/MED) β€” yes it's all official and proper, standard-approved and everything. πŸ’–

BUT. two little caveats, ngl:

  • the standard only allows one foreign table to be dropped per command (we let you do a whole list, we're generous like that 😌)
  • and the IF EXISTS option is a PostgreSQL extension β€” so that part? that's us. that's our thing. πŸ’…

🌈 SEE ALSO 🌈

like, if you're out here dropping things you probably also wanna know how to make them and change them. balance. πŸ¦‹


and that's the page, bestie!! πŸ’– this lil rewrite comes to you courtesy of the PostgreSQL 17.11 docs, dated 2026 β€” go off and drop those foreign tables responsibly (with RESTRICT, ideally, since it's the default and honestly kind of a vibe). πŸŽ€πŸ«Άβœ¨

πŸ“¦ where this page comes from