DROP_DOMAIN(7)

๐Ÿ’– DROP DOMAIN ๐Ÿ’–

okay bestie, so you know what a domain is? it's like a custom type with โœจrulesโœจ and we're about to say bye to one. this page is from the PostgreSQL 18.6 Documentation, section 7 (that's the SQL commands girlies), and it's called DROP DOMAIN. yes it's literally the manual page for dropping a domain. iconic. let's go ๐Ÿ’…


๐ŸŒธ NAME ๐ŸŒธ

DROP_DOMAIN โ€” bestie we are removing a domain. that's it. that's the whole job. ๐ŸŽ€


โœจ SYNOPSIS โœจ

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

look at her. so clean. so simple. one line and a whole domain is gone. ๐Ÿ˜ญ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

DROP DOMAIN removes a domain. periodt. ๐Ÿ’€

but listen โ€” and this is the important part, don't skip it โ€” only the owner of a domain can remove it. so if it's not yours, hands off, no cap. ๐Ÿ‘‘


๐Ÿ’œ PARAMETERS ๐Ÿ’œ

okay so the options, one by one, no skipping, we're thorough in this house:

  • IF EXISTS โ€” don't throw an error if the domain doesn't even exist, like, be chill about it. in that case a notice gets issued instead. very "no drama" of you. ๐Ÿซถ
  • name โ€” the name of an existing domain, optionally schema-qualified. yep. it can be schema-qualified. that's your girl. ๐ŸŒˆ
  • CASCADE โ€” automatically drop objects that depend on the domain (think table columns, bestie), and then in turn all the objects that depend on those objects too. it's giving domino effect. it's giving chain reaction. see Section 5.15 for the whole saga. ๐Ÿ”ฅ
  • RESTRICT โ€” refuse to drop the domain if any objects depend on it. she said "no, we're not doing that." and guess what? this is the default, so if you don't say anything, this is what you get. ๐Ÿ’…
ok real talk for a sec: CASCADE is the loud one at the party that takes everyone else down with her. RESTRICT is the responsible friend. choose wisely bestie. ๐Ÿ˜ญ

๐ŸŒŸ EXAMPLES ๐ŸŒŸ

say you wanna remove the domain box. (the domain is literally named box. cute.) you do:

DROP DOMAIN box;

and she's gone. bye girl ๐Ÿ’–


โญ COMPATIBILITY โญ

this command conforms to the SQL standard... except for the IF EXISTS option, which is a PostgreSQL extension. so if you're out here flexing IF EXISTS in another database, that's a you problem, ngl. ๐Ÿ™ˆ


๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ

the whole family, go read them:

  • CREATE DOMAIN (CREATE_DOMAIN(7)) โ€” for making one in the first place ๐ŸŽ€
  • ALTER DOMAIN (ALTER_DOMAIN(7)) โ€” for changing your mind about it ๐Ÿฆ‹

anyway that's the page!! go forth and drop responsibly, you main character ๐Ÿ’œโœจ

this has been PostgreSQL 18.6, dated 2026, and the page is DROP DOMAIN(7) โ€” mwah, slay, bye bestie ๐Ÿ’…๐ŸŽ€๐Ÿซถ