DROP_TYPE(7pg16)

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

πŸ’… DROP TYPE πŸ’…

ok so this is the PostgreSQL 16.15 Documentation page for DROP TYPE, bestie β€” we're gonna delete a data type together and it's gonna be so clean ✨


🌸 NAME 🌸

DROP_TYPE β€” bestie, this is how you remove a data type. bye-bye type πŸ‘‹


πŸ¦‹ SYNOPSIS πŸ¦‹

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

like, that's the whole vibe. look at it. iconic πŸ’…


✨ DESCRIPTION ✨

okay so DROP TYPE removes a user-defined data type. that's the whole job, no notes.

but here's the thing, and I need you to hear me on this: only the owner of a type can remove it. so if you're not the owner, sorry bestie, the vibes are not immaculate and the command is not gonna work 😭


πŸŽ€ PARAMETERS πŸŽ€

  • IF EXISTS β€” do not throw an error if the type doesn't exist. instead it just issues a notice. so like, no dramatic meltdown, just a lil "hey, heads up" 🫢
  • name β€” the name of the data type you're removing. it can be optionally schema-qualified if you're being fancy about it πŸ’…
  • CASCADE β€” this one is main character energy and also slightly terrifying ngl. it automatically drops objects that depend on the type (think table columns, functions, and operators), and then in turn all objects that depend on those objects. it's giving domino effect πŸ’€ (see Section 5.14)
  • RESTRICT β€” refuses to drop the type if any objects depend on it. this is the default, so if you don't say anything, this is what you get 🌈
πŸ‘‘ lowkey reminder: CASCADE takes the whole friend group down with it. RESTRICT says "nope, not on my watch." choose wisely bestie 🫢

πŸ“ EXAMPLES πŸ“

to remove the data type box:

DROP TYPE box;

that's it. one line. ate and left no crumbs ✨


🧚 COMPATIBILITY 🧚

so this command is similar to the corresponding command in the SQL standard β€” except for the IF EXISTS option, which is a PostgreSQL extension (very much its own thing, we love that for it πŸ’œ).

but also, important caveat: note that much of the CREATE TYPE command and the data type extension mechanisms in PostgreSQL differ from the SQL standard. so yeah, similar β‰  identical, iykyk πŸ™ˆ


πŸ’– SEE ALSO πŸ’–

go read those too, they're literally so good, fr fr πŸ”₯


made with love by PostgreSQL 16.15 πŸ¦‹ dated 2026 πŸŽ€ this was DROP TYPE(7) and you slayed it πŸ’…βœ¨

πŸ“¦ where this page comes from