DROP_TYPE(7pg16)
π 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:CASCADEtakes the whole friend group down with it.RESTRICTsays "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 π
ALTER TYPE(ALTER_TYPE(7))CREATE TYPE(CREATE_TYPE(7))
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
- 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