DROP_FOREIGN_TABLE(7pg14)

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

πŸ’… 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 EXISTS option, which is a PostgreSQL extension 🐘✨

πŸ’œ SEE ALSO πŸ’œ

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