2 .\" Title: ALTER OPERATOR
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "ALTER OPERATOR" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 ALTER_OPERATOR \- change the definition of an operator
35 ALTER OPERATOR \fIname\fR ( { \fIleft_type\fR | NONE } , \fIright_type\fR )
36 OWNER TO { \fInew_owner\fR | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
38 ALTER OPERATOR \fIname\fR ( { \fIleft_type\fR | NONE } , \fIright_type\fR )
39 SET SCHEMA \fInew_schema\fR
41 ALTER OPERATOR \fIname\fR ( { \fIleft_type\fR | NONE } , \fIright_type\fR )
42 SET ( { RESTRICT = { \fIres_proc\fR | NONE }
43 | JOIN = { \fIjoin_proc\fR | NONE }
44 | COMMUTATOR = \fIcom_op\fR
45 | NEGATOR = \fIneg_op\fR
53 changes the definition of an operator\&.
55 You must own the operator to use
56 \fBALTER OPERATOR\fR\&. To alter the owner, you must be able to
58 to the new owning role, and that role must have
60 privilege on the operator\*(Aqs schema\&. (These restrictions enforce that altering the owner doesn\*(Aqt do anything you couldn\*(Aqt do by dropping and recreating the operator\&. However, a superuser can alter ownership of any operator anyway\&.)
65 The name (optionally schema\-qualified) of an existing operator\&.
70 The data type of the operator\*(Aqs left operand; write
72 if the operator has no left operand\&.
77 The data type of the operator\*(Aqs right operand\&.
82 The new owner of the operator\&.
87 The new schema for the operator\&.
92 The restriction selectivity estimator function for this operator; write NONE to remove existing selectivity estimator\&.
97 The join selectivity estimator function for this operator; write NONE to remove existing selectivity estimator\&.
102 The commutator of this operator\&. Can only be changed if the operator does not have an existing commutator\&.
107 The negator of this operator\&. Can only be changed if the operator does not have an existing negator\&.
112 Indicates this operator can support a hash join\&. Can only be enabled and not disabled\&.
117 Indicates this operator can support a merge join\&. Can only be enabled and not disabled\&.
125 for further information\&.
127 Since commutators come in pairs that are commutators of each other,
128 ALTER OPERATOR SET COMMUTATOR
129 will also set the commutator of the
131 to be the target operator\&. Likewise,
132 ALTER OPERATOR SET NEGATOR
133 will also set the negator of the
135 to be the target operator\&. Therefore, you must own the commutator or negator operator as well as the target operator\&.
138 Change the owner of a custom operator
147 ALTER OPERATOR @@ (text, text) OWNER TO joe;
153 Change the restriction and join selectivity estimator functions of a custom operator
162 ALTER OPERATOR && (int[], int[]) SET (RESTRICT = _int_contsel, JOIN = _int_contjoinsel);
170 operator as being its own commutator:
176 ALTER OPERATOR && (int[], int[]) SET (COMMUTATOR = &&);
186 statement in the SQL standard\&.
188 CREATE OPERATOR (\fBCREATE_OPERATOR\fR(7)), DROP OPERATOR (\fBDROP_OPERATOR\fR(7))