DROP_OPERATOR(7pg17)
π DROP_OPERATOR π
okay bestie so you've got an operator in your database and it's giving clutter, and you need it GONE. That's this page β DROP OPERATOR from the PostgreSQL 17.11 docs. Buckle up, it's a short one but we're gonna make it iconic β¨
β¨ NAME β¨
DROP_OPERATOR β remove an operator ποΈπ
π SYNOPSIS π
DROP OPERATOR [ IF EXISTS ] name ( { left_type | NONE } , right_type ) [, ...] [ CASCADE | RESTRICT ]
like literally just look at that. so much power in one line π«Ά
πΈ DESCRIPTION πΈ
DROP OPERATOR drops an existing operator from the database system. yep. that's the whole vibe. β¨
but hear me β to execute this command you must be the owner of the operator. no exceptions, no "but bestie π₯Ί". if it's not yours, it's not yours. periodt. π
π¦ PARAMETERS π¦
IF EXISTSβ do not throw an error if the operator doesn't exist. instead it just issues a notice, so your script doesn't blow up over a ghost operator π» highkey a lifesaver.nameβ the name of an existing operator, optionally schema-qualified. iykyk πleft_typeβ the data type of the operator's left operand. and if the operator has no left operand? writeNONE. yes, literally the wordNONE. she's self-explanatory like that πββοΈright_typeβ the data type of the operator's right operand. noNONEoption here, it's right operand main character energy only πCASCADEβ automatically drop objects that depend on the operator (think views using it), and then in turn all objects that depend on those objects. it's giving domino effect. see Section 5.15 for the full lore ππ₯RESTRICTβ refuse to drop the operator if any objects depend on it. and heads up: this is the default. so if you don't say anything, she's cautious ππ
π EXAMPLES π
remove the power operator a^b for type integer:
DROP OPERATOR ^ (integer, integer);
remove the bitwise-complement prefix operator ~b for type bit:
DROP OPERATOR ~ (none, bit);
and the flex β remove multiple operators in ONE command:
DROP OPERATOR ~ (none, bit), ^ (integer, integer);
not me doing two drops in a single line π ate and left no crumbs π§ββοΈ
π COMPATIBILITY π
sobbing. there is no DROP OPERATOR statement in the SQL standard. this is a PostgreSQL original, bestie πβ
π₯ SEE ALSO π₯
CREATE OPERATOR(CREATE_OPERATOR(7))ALTER OPERATOR(ALTER_OPERATOR(7))
go read those too, they're the siblings of this page fr fr π
ngl the whole takeaway here is: check who owns the operator, rememberRESTRICTis the default so nothing catastrophic happens by accident, and only reach forCASCADEwhen you actually mean it π
okay that's the page!! go forth and drop responsibly, bestie π«Άβ¨π
β written with love from the PostgreSQL 17.11 documentation, dated 2026 π π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-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