DROP_TABLE(7pg16)

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

🌸 NAME 🌸

okay so DROP_TABLE β€” remove a table. this is the DROP_TABLE(7pg16) manual page from the PostgreSQL 16.15 docs, and bestie we are absolutely getting into it πŸ’…βœ¨

✨ SYNOPSIS ✨

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

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so DROP TABLE removes tables from the database. only the table owner, the schema owner, and superuser can drop a table. to empty a table of rows without destroying the table, use DELETE or TRUNCATE. 🧚

DROP TABLE always removes any indexes, rules, triggers, and constraints that exist for the target table. however, to drop a table that is referenced by a view or a foreign-key constraint of another table, CASCADE must be specified. (and yes, 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.) πŸ’€

πŸŽ€ PARAMETERS πŸŽ€

  • IF EXISTS β€” do not throw an error if the table does not exist. a notice is issued in this case. πŸ‘€
  • name β€” the name (optionally schema-qualified) of the table to drop. 🏷️
  • 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.14). πŸ”₯
  • RESTRICT β€” refuse to drop the table if any objects depend on it. this is the default. πŸ›‘

🌈 EXAMPLES 🌈

to destroy two tables, films and distributors:

DROP TABLE films, distributors;

πŸ‘‘ COMPATIBILITY πŸ‘‘

this command conforms to the SQL standard, except that the standard only allows one table to be dropped per command, and apart from the IF EXISTS option, which is a PostgreSQL extension. ✨

🫢 SEE ALSO 🫢


k that's the whole page bestie 🫢 β€” mwah πŸ’‹. this was PostgreSQL 16.15, dated 2026, page DROP TABLE(7). you ate that, no cap. periodt ✨

πŸ“¦ where this page comes from