DROP_OPERATOR_FAMILY(7pg14)

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

πŸ’… DROP OPERATOR FAMILY πŸ’…

okay bestie, so this one is from the PostgreSQL 14.24 docs and it's literally the page for yeeting an operator family out of existence. yes, that's a real thing, and yes, you're gonna slay it 🫢


✨ NAME ✨

DROP OPERATOR FAMILY β€” remove an operator family

🌸 SYNOPSIS 🌸

DROP OPERATOR FAMILY [ IF EXISTS ] name USING index_method [ CASCADE | RESTRICT ]

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so DROP OPERATOR FAMILY drops an existing operator family. that's the whole vibe. but β€” and this is the part where you need to check yourself β€” to actually run this command you must be the owner of the operator family. no ownership, no drop, periodt. πŸ‘‘

here's the tea though: DROP OPERATOR FAMILY does include dropping any operator classes contained in the family. so those go bye-bye too. but it does NOT drop any of the operators or functions referenced by the family β€” those are safe, they stay. so don't panic, your functions are fine πŸ’–

and if there are any indexes depending on operator classes within the family? yeah, you're gonna need to specify CASCADE for the drop to complete. it's giving "you can't just leave, you have to take everyone with you" energy ngl 😭

πŸŽ€ PARAMETERS πŸŽ€

  • IF EXISTS β€” do not throw an error if the operator family does not exist. a notice is issued in this case instead. so like, it's the chill version β€” no dramatic error, just a lil heads up 🌸
  • name β€” the name (optionally schema-qualified) of an existing operator family. yep, you can qualify it with the schema, that's allowed and lowkey useful πŸ¦‹
  • index_method β€” the name of the index access method the operator family is for. you gotta tell it which one, it's not a mind reader πŸ’…
  • CASCADE β€” automatically drop objects that depend on the operator family, and in turn all objects that depend on those objects (see Section 5.14). yeah it's the domino effect, everything connected goes down with it πŸ”₯
  • RESTRICT β€” refuse to drop the operator family if any objects depend on it. this is the default. so if you don't say anything, it's gonna be cautious about it, which honestly? valid πŸ™ˆ

🌈 EXAMPLES 🌈

remove the B-tree operator family float_ops:

DROP OPERATOR FAMILY float_ops USING btree;

okay but heads up bestie: this command will not succeed if there are any existing indexes that use operator classes within the family. add CASCADE to drop such indexes along with the operator family. so if it's throwing hands at you, that's why 😀

⭐ COMPATIBILITY ⭐

there is literally no DROP OPERATOR FAMILY statement in the SQL standard. none. zero. it's not a thing there. so like, this is very much a PostgreSQL main character moment πŸ‘‘

πŸ’œ SEE ALSO πŸ’œ

like, go read those too, they're all connected, iykyk 🧚


and that's the whole page, bestie! this one's from PostgreSQL 14.24 and the docs are dated 2026 β€” so go forth and drop those operator families responsibly, mwah πŸ’‹βœ¨πŸŒΈ

πŸ“¦ where this page comes from