DROP_TABLE(7pg16)
πΈ 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 (seeSection 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 π«Ά
ALTER TABLE(ALTER_TABLE(7))CREATE TABLE(CREATE_TABLE(7))
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
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms