DROP_OPERATOR_CLASS(7pg14)
π 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 π¦
ALTER OPERATOR CLASS(ALTER_OPERATOR_CLASS(7))CREATE OPERATOR CLASS(CREATE_OPERATOR_CLASS(7))DROP OPERATOR FAMILY(DROP_OPERATOR_FAMILY(7))
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
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-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