DROP_TABLE(7)
💅 DROP TABLE — the manual page, but make it a group chat
ok so bestie, welcome to DROP_TABLE from the PostgreSQL 18.6 docs. it's giving "the nuclear option, but make it cute". let's get into it 🎀
✨ NAME ✨
DROP_TABLE — remove a table 💀 (yes. gone. bye.)
✨ SYNOPSIS ✨
DROP TABLE [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
look at her. short. powerful. terrifying. iconic 🌈
✨ DESCRIPTION ✨
okay so DROP TABLE removes tables from the database. periodt. 💅
but hold up — not just anyone can do this. only the table owner, the schema owner, and superuser can drop a table. so if you're not on that list, sorry bestie, it's not happening 🙈
also important: if you just wanna empty a table of rows without destroying the table, do NOT drop it. use DELETE or TRUNCATE instead. different vibes entirely, iykyk.
now for the tea 🍓: DROP TABLE always removes any indexes, rules, triggers, and constraints that exist for the target table. she does not leave loose ends. she cleans up. main character energy fr fr.
BUT. and this is the big but. if you wanna drop a table that's referenced by a view or a foreign-key constraint of another table, you gotta say CASCADE. no CASCADE, no drop.
and lowkey the details matter here: CASCADE will remove a dependent view entirely, but in the foreign-key case it will only remove the foreign-key constraint, not the other table entirely. so she's dramatic but she's precise. obsessed actually.
✨ PARAMETERS ✨
IF EXISTS— don't throw an error if the table doesn't exist. she's not gonna yell at you for dropping something that's already gone. a notice is issued in this case, so you'll still know what's up. 🫶name— the name of the table to drop. optionally schema-qualified, so likemyschema.mytableif you're feeling specific.CASCADE— automatically drop objects that depend on the table (such as views), and in turn all objects that depend on those objects (see Section 5.15). yes, that's a chain reaction. yes, it can get big. she said "and i took that personally". 🔥RESTRICT— refuse to drop the table if any objects depend on it. this is the default. she's cautious. she's responsible. she's the friend who says "bestie are you SURE" 💖
✨ EXAMPLES ✨
wanna destroy two tables, films and distributors? okay. say less:
DROP TABLE films, distributors;
and that's it. no takebacks. no undo button. just vibes and consequences 💀✨
✨ COMPATIBILITY ✨
ok so this command conforms to the SQL standard, except for two lil things:
- the standard only allows one table to be dropped per command (we allow a whole list, we're generous like that 🎀)
- the
IF EXISTSoption, which is a PostgreSQL extension — standard doesn't have it, we do 🦋
✨ SEE ALSO ✨
ALTER TABLE(ALTER_TABLE(7))CREATE TABLE(CREATE_TABLE(7))
go read those if you wanna create instead of destroy. balance, bestie 🌸
⚠️ real talk: dropping a table is permanent. there is no "oops undo". CASCADE especially can take down a whole chain of dependent stuff. read twice, drop once. 💀
and that's the whole page!! 💖 this one's from PostgreSQL 18.6, dated 2026 — so if you're reading this in some other year, hi from the past, hope your tables are safe 🫶✨ bye bestie!! 🎀🦋💅
📦 where this page comes from
- alpine 3.23: postgresql18-doc 18.6-r0 · PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 · PostgreSQL
- arch rolling: postgresql 18.6-4 · PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 · PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 · PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 · PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 · PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-client-18 18.6-0ubuntu0.26.04.1 · PostgreSQL
- ubuntu stonking: postgresql-client-18 18.6-3build2 · PostgreSQL
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms