DROP_OPERATOR(7pg13)
π DROP OPERATOR π
okay bestie, so this is the <pink>DROP OPERATOR</pink> page from the PostgreSQL 13 docs (7pg13, we love a reference manual moment) β and it's literally the "bye bitch" button for operators in your database. Let's get into it π«Ά
β¨ SYNOPSIS β¨
DROP OPERATOR [ IF EXISTS ] name ( { left_type | NONE } , { right_type | NONE } ) [, ...] [ CASCADE | RESTRICT ]
no cap, that's the whole thing. it's giving "one line, all the power" π
πΈ DESCRIPTION πΈ
DROP OPERATOR drops an existing operator from the database system. that's it, that's the vibe β the operator is gone, poof, iconic exit π¨β¨
but listen, <red>you must be the owner of the operator</red> to run this command. like, ownership check first, always. fr fr don't try it if it's not yours, it's not giving main character energy π
π PARAMETERS π
IF EXISTSβ do not throw an error if the operator doesn't exist. instead you just get a notice issued in this case. lowkey polite, highkey useful πnameβ the name of an existing operator, optionally schema-qualified. yes you can be fancy with the schema quals β¨left_typeβ the data type of the operator's left operand. and if the operator has no left operand, you literally writeNONE. not "nothing", not blank βNONE. periodt πright_typeβ the data type of the operator's right operand. same deal: writeNONEif the operator has no right operand πCASCADEβ automatically drop objects that depend on the operator (such as views using it), and in turn all objects that depend on those objects (see Section 5.14). it's giving ripple effect, it's giving chain reaction π₯ careful tho, that's a lot of collateral πRESTRICTβ refuse to drop the operator if any objects depend on it. and guess what bestie, this is the default. so unless you say otherwise, it's a hard no on the cascade vibes πβ
π¦ EXAMPLES π¦
remove the power operator a^b for type integer:
DROP OPERATOR ^ (integer, integer);
remove the left unary bitwise complement operator ~b for type bit:
DROP OPERATOR ~ (none, bit);
remove the right unary factorial operator x! for type bigint:
DROP OPERATOR ! (bigint, none);
remove multiple operators in one command β yes you can do a whole batch, we love efficiency π
DROP OPERATOR ~ (none, bit), ! (bigint, none);
π COMPATIBILITY π
ngl, there is <hotpink>no DROP OPERATOR statement in the SQL standard</hotpink>. it's a PostgreSQL exclusive little moment, iykyk π
π SEE ALSO π
CREATE OPERATOR(CREATE_OPERATOR(7))ALTER OPERATOR(ALTER_OPERATOR(7))
bestie reminder okay:<yellow>CASCADE</yellow>is fun until it's not. it'll take the dependent views and everything hanging off those too. if you're not sure, stick with the defaultRESTRICTand vibe check your dependencies first ππ
mwah π this was PostgreSQL 13.23 documentation, dated 2025, page DROP OPERATOR(7) β go forth and drop responsibly, queen πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-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