DROP_OPERATOR_CLASS(7pg14)

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

πŸ’… DROP_OPERATOR_CLASS πŸ’…

okay bestie, so this is the DROP OPERATOR_CLASS page from the PostgreSQL 14.24 docs β€” yes, that's DROP OPERATOR CLASS, the one that goes poof on an operator class. iykyk πŸ¦‹


✨ SYNOPSIS ✨

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

like, that's the whole vibe. read it, memorise it, slay. πŸ‘‘


🌸 DESCRIPTION 🌸

so DROP OPERATOR CLASS drops an existing operator class. that's it, that's the job. πŸ’…

but β€” and this is the main character rule β€” to actually run this command you must be the owner of the operator class. no ownership, no dropping. periodt.

also important: DROP OPERATOR CLASS does not drop any of the operators or functions referenced by the class. they stay. they're fine. they're thriving. 🫢

and if there are any indexes depending on the operator class, you'll need to specify CASCADE for the drop to complete. no cascade, no completion. 😭


πŸŽ€ PARAMETERS πŸŽ€

  • IF EXISTS β€” do not throw an error if the operator class does not exist. a notice is issued in this case. so like, no dramatic meltdown if it's already gone, just a lil heads up. πŸ™ˆ
  • name β€” the name (optionally schema-qualified) of an existing operator class. yes, schema-qualified is allowed, go off. ✨
  • index_method β€” the name of the index access method the operator class is for. it's giving "which index access method is this for" energy. πŸ’–
  • CASCADE β€” automatically drop objects that depend on the operator class (such as indexes), and in turn all objects that depend on those objects (see Section 5.14). it's a whole chain reaction, lowkey iconic. πŸ”₯
  • RESTRICT β€” refuse to drop the operator class if any objects depend on it. this is the default. the cautious queen we all need. πŸ‘‘

πŸ’€ NOTES πŸ’€

DROP OPERATOR CLASS will not drop the operator family containing the class, even if there is nothing else left in the family β€” in particular, in the case where the family was implicitly created by CREATE OPERATOR CLASS. 😳

an empty operator family is harmless, but for the sake of tidiness you might wish to remove the family with DROP OPERATOR FAMILY; or perhaps better, use DROP OPERATOR FAMILY in the first place. ngl that last tip is the real slay. 🧚


🌈 EXAMPLES 🌈

remove the B-tree operator class widget_ops:

DROP OPERATOR CLASS widget_ops USING btree;
⭐ heads up bestie: this command will not succeed if there are any existing indexes that use the operator class. add CASCADE to drop such indexes along with the operator class. πŸ’…

🌟 COMPATIBILITY 🌟

there is no DROP OPERATOR CLASS statement in the SQL standard. so cute of the standard, honestly. it's giving "we don't do that here". πŸ’€


πŸ¦‹ SEE ALSO πŸ¦‹


mwah πŸ’‹ this has been your girl walking you through DROP OPERATOR CLASS(7), straight outta the PostgreSQL 14.24 documentation, dated 2026. go forth and drop responsibly, bestie. πŸŽ€βœ¨

πŸ“¦ where this page comes from