DROP_TABLE(7pg14)

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

πŸŽ€ NAME πŸŽ€

okay so bestie, this is the DROP_TABLE(7pg14) page β€” aka DROP TABLE β€” and it's literally about how to remove a table from your PostgreSQL 14.24 database. πŸ’…

✨ SYNOPSIS ✨

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

πŸ’– DESCRIPTION πŸ’–

DROP TABLE removes tables from the database, no cap. Only the table owner, the schema owner, and superuser can drop a table. If you just wanna empty a table of rows without destroying the table itself, use DELETE or TRUNCATE instead. slay. 🌸

DROP TABLE always removes any indexes, rules, triggers, and constraints that exist for the target table. Iconic cleanup energy. But if you need to drop a table that's referenced by a view or a foreign-key constraint of another table, you must specify CASCADE. (And here's the tea: 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. periodt. ✨

πŸ’œ SEE ALSO πŸ’œ


🫢 that's the whole DROP_TABLE(7pg14) situation, bestie! source/version: PostgreSQL 14.24 Β· date: 2026 Β· now go drop tables responsibly πŸ’–

πŸ“¦ where this page comes from