DROP_OPERATOR_FAMILY(7pg13)

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

πŸ’… DROP OPERATOR FAMILY πŸ’…

Okay so bestie, welcome to the glow-up guide for DROP OPERATOR FAMILY β€” this is the PostgreSQL 13 move where you literally just yeet an operator family out of existence. Periodt.


✨ NAME ✨

DROP_OPERATOR_FAMILY β€” remove an operator family πŸ—‘οΈβœ¨


πŸŽ€ SYNOPSIS πŸŽ€

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

🌸 DESCRIPTION 🌸

So like, DROP OPERATOR FAMILY drops an existing operator family. That's the whole vibe. But heads up β€” to run this command you must be the owner of the operator family. No borrowing your friend's credentials, bestie. πŸ‘‘

And here's the tea: DROP OPERATOR FAMILY includes dropping any operator classes contained in the family, but it does not drop any of the operators or functions referenced by the family. So those little guys stay living their best life. πŸ¦‹

Also, if there are any indexes depending on operator classes within the family, you will need to specify CASCADE for the drop to complete. Like, it's giving "I can't do this alone" energy. 😭


πŸ¦‹ PARAMETERS πŸ¦‹

  • IF EXISTS β€” Do not throw an error if the operator family does not exist. A notice is issued in this case. Basically: if it's not there, we just move on gracefully. πŸ’β€β™€οΈ
  • name β€” The name (optionally schema-qualified) of an existing operator family. You know, its whole identity. πŸ’–
  • index_method β€” The name of the index access method the operator family is for. Like btree, hash, etc. β€” every family has its method, iykyk. πŸ”₯
  • CASCADE β€” Automatically drop objects that depend on the operator family, and in turn all objects that depend on those objects (see Section 5.14). It's the domino effect, bestie β€” once one falls, they all fall. πŸ’€
  • RESTRICT β€” Refuse to drop the operator family if any objects depend on it. This is the default. So if you're not sure, it's lowkey protecting you. πŸ›‘οΈ

🌈 EXAMPLES 🌈

Remove the B-tree operator family float_ops:

DROP OPERATOR FAMILY float_ops USING btree;

Now listen β€” 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 you're getting errors, that's why. Not me forgetting, it's literally in the docs. πŸ™ˆ


🧚 COMPATIBILITY 🧚

There is no DROP OPERATOR FAMILY statement in the SQL standard. So like, we're built different. PostgreSQL said "I'll make my own rules." πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘


That's the whole main character moment, bestie. This guide is from PostgreSQL 13.23 and it's dated 2025 β€” literally iconic. Go drop those operator families responsibly. Slay. ✨🫢🌸

πŸ“¦ where this page comes from