ALTER_OPERATOR(7pg16)
πΈ NAME πΈ
ALTER_OPERATOR(7pg16) β bestie, this is the PostgreSQL 16.15 page for changing the definition of an operator. Itβs giving βoperator glow-upβ β¨.
β¨ SYNOPSIS β¨
ALTER OPERATOR name ( { left_type | NONE } , right_type )
OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER OPERATOR name ( { left_type | NONE } , right_type )
SET SCHEMA new_schema
ALTER OPERATOR name ( { left_type | NONE } , right_type )
SET ( { RESTRICT = { res_proc | NONE }
| JOIN = { join_proc | NONE }
} [, ... ] )
π DESCRIPTION π
Okay so ALTER OPERATOR changes the definition of an operator. Thatβs the whole vibe.
You must own the operator to use ALTER OPERATOR. To alter the owner, you must be able to SET ROLE to the new owning role, and that role must have CREATE privilege on the operatorβs schema. These restrictions enforce that altering the owner doesnβt do anything you couldnβt do by dropping and recreating the operator. However, a superuser can alter ownership of any operator anyway. π
π PARAMETERS π
nameβ the name (optionally schema-qualified) of an existing operator.left_typeβ the data type of the operatorβs left operand; writeNONEif the operator has no left operand.right_typeβ the data type of the operatorβs right operand.new_ownerβ the new owner of the operator.new_schemaβ the new schema for the operator.res_procβ the restriction selectivity estimator function for this operator; writeNONEto remove existing selectivity estimator.join_procβ the join selectivity estimator function for this operator; writeNONEto remove existing selectivity estimator.
π¦ EXAMPLES π¦
Change the owner of a custom operator a @@ b for type text:
ALTER OPERATOR @@ (text, text) OWNER TO joe;
Change the restriction and join selectivity estimator functions of a custom operator a && b for type int[]:
ALTER OPERATOR && (_int4, _int4) SET (RESTRICT = _int_contsel, JOIN = _int_contjoinsel);
π COMPATIBILITY π
There is no ALTER OPERATOR statement in the SQL standard. The SQL standard really said βnot todayβ π.
π₯ SEE ALSO π₯
CREATE OPERATOR(CREATE_OPERATOR(7))DROP OPERATOR(DROP_OPERATOR(7))
Signing off from ALTER_OPERATOR(7) β PostgreSQL 16.15, 2026 edition π«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-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