2 .\" Title: ALTER OPERATOR FAMILY
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 FAMILY" "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_FAMILY \- change the definition of an operator family
35 ALTER OPERATOR FAMILY \fIname\fR USING \fIindex_method\fR ADD
36 { OPERATOR \fIstrategy_number\fR \fIoperator_name\fR ( \fIop_type\fR, \fIop_type\fR )
37 [ FOR SEARCH | FOR ORDER BY \fIsort_family_name\fR ]
38 | FUNCTION \fIsupport_number\fR [ ( \fIop_type\fR [ , \fIop_type\fR ] ) ]
39 \fIfunction_name\fR [ ( \fIargument_type\fR [, \&.\&.\&.] ) ]
42 ALTER OPERATOR FAMILY \fIname\fR USING \fIindex_method\fR DROP
43 { OPERATOR \fIstrategy_number\fR ( \fIop_type\fR [ , \fIop_type\fR ] )
44 | FUNCTION \fIsupport_number\fR ( \fIop_type\fR [ , \fIop_type\fR ] )
47 ALTER OPERATOR FAMILY \fIname\fR USING \fIindex_method\fR
48 RENAME TO \fInew_name\fR
50 ALTER OPERATOR FAMILY \fIname\fR USING \fIindex_method\fR
51 OWNER TO { \fInew_owner\fR | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
53 ALTER OPERATOR FAMILY \fIname\fR USING \fIindex_method\fR
54 SET SCHEMA \fInew_schema\fR
58 \fBALTER OPERATOR FAMILY\fR
59 changes the definition of an operator family\&. You can add operators and support functions to the family, remove them from the family, or change the family\*(Aqs name or owner\&.
61 When operators and support functions are added to a family with
62 \fBALTER OPERATOR FAMILY\fR, they are not part of any specific operator class within the family, but are just
64 within the family\&. This indicates that these operators and functions are compatible with the family\*(Aqs semantics, but are not required for correct functioning of any specific index\&. (Operators and functions that are so required should be declared as part of an operator class, instead; see
65 CREATE OPERATOR CLASS (\fBCREATE_OPERATOR_CLASS\fR(7))\&.)
67 will allow loose members of a family to be dropped from the family at any time, but members of an operator class cannot be dropped without dropping the whole class and any indexes that depend on it\&. Typically, single\-data\-type operators and functions are part of operator classes because they are needed to support an index on that specific data type, while cross\-data\-type operators and functions are made loose members of the family\&.
69 You must be a superuser to use
70 \fBALTER OPERATOR FAMILY\fR\&. (This restriction is made because an erroneous operator family definition could confuse or even crash the server\&.)
72 \fBALTER OPERATOR FAMILY\fR
73 does not presently check whether the operator family definition includes all the operators and functions required by the index method, nor whether the operators and functions form a self\-consistent set\&. It is the user\*(Aqs responsibility to define a valid operator family\&.
77 for further information\&.
82 The name (optionally schema\-qualified) of an existing operator family\&.
87 The name of the index method this operator family is for\&.
92 The index method\*(Aqs strategy number for an operator associated with the operator family\&.
97 The name (optionally schema\-qualified) of an operator associated with the operator family\&.
104 clause, the operand data type(s) of the operator, or
106 to signify a prefix operator\&. Unlike the comparable syntax in
107 \fBCREATE OPERATOR CLASS\fR, the operand data types must always be specified\&.
111 clause, the operand data type(s) the function is intended to support, if different from the input data type(s) of the function\&. For B\-tree comparison functions and hash functions it is not necessary to specify
113 since the function\*(Aqs input data type(s) are always the correct ones to use\&. For B\-tree sort support functions, B\-Tree equal image functions, and all functions in GiST, SP\-GiST and GIN operator classes, it is necessary to specify the operand data type(s) the function is to be used with\&.
117 clause, the operand data type(s) the function is intended to support must be specified\&.
120 \fIsort_family_name\fR
122 The name (optionally schema\-qualified) of an existing
124 operator family that describes the sort ordering associated with an ordering operator\&.
137 The index method\*(Aqs support function number for a function associated with the operator family\&.
142 The name (optionally schema\-qualified) of a function that is an index method support function for the operator family\&. If no argument list is specified, the name must be unique in its schema\&.
147 The parameter data type(s) of the function\&.
152 The new name of the operator family\&.
157 The new owner of the operator family\&.
162 The new schema for the operator family\&.
169 clauses can appear in any order\&.
174 syntax only specifies the
176 in the operator family, by strategy or support number and input data type(s)\&. The name of the operator or function occupying the slot is not mentioned\&. Also, for
178 the type(s) to specify are the input data type(s) the function is intended to support; for GiST, SP\-GiST and GIN indexes this might have nothing to do with the actual input argument types of the function\&.
180 Because the index machinery does not check access permissions on functions before using them, including a function or operator in an operator family is tantamount to granting public execute permission on it\&. This is usually not an issue for the sorts of functions that are useful in an operator family\&.
182 The operators should not be defined by SQL functions\&. An SQL function is likely to be inlined into the calling query, which will prevent the optimizer from recognizing that the query matches an index\&.
185 The following example command adds cross\-data\-type operators and support functions to an operator family that already contains B\-tree operator classes for data types
194 ALTER OPERATOR FAMILY integer_ops USING btree ADD
197 OPERATOR 1 < (int4, int2) ,
198 OPERATOR 2 <= (int4, int2) ,
199 OPERATOR 3 = (int4, int2) ,
200 OPERATOR 4 >= (int4, int2) ,
201 OPERATOR 5 > (int4, int2) ,
202 FUNCTION 1 btint42cmp(int4, int2) ,
205 OPERATOR 1 < (int2, int4) ,
206 OPERATOR 2 <= (int2, int4) ,
207 OPERATOR 3 = (int2, int4) ,
208 OPERATOR 4 >= (int2, int4) ,
209 OPERATOR 5 > (int2, int4) ,
210 FUNCTION 1 btint24cmp(int2, int4) ;
216 To remove these entries again:
222 ALTER OPERATOR FAMILY integer_ops USING btree DROP
225 OPERATOR 1 (int4, int2) ,
226 OPERATOR 2 (int4, int2) ,
227 OPERATOR 3 (int4, int2) ,
228 OPERATOR 4 (int4, int2) ,
229 OPERATOR 5 (int4, int2) ,
230 FUNCTION 1 (int4, int2) ,
233 OPERATOR 1 (int2, int4) ,
234 OPERATOR 2 (int2, int4) ,
235 OPERATOR 3 (int2, int4) ,
236 OPERATOR 4 (int2, int4) ,
237 OPERATOR 5 (int2, int4) ,
238 FUNCTION 1 (int2, int4) ;
246 \fBALTER OPERATOR FAMILY\fR
247 statement in the SQL standard\&.
249 CREATE OPERATOR FAMILY (\fBCREATE_OPERATOR_FAMILY\fR(7)), DROP OPERATOR FAMILY (\fBDROP_OPERATOR_FAMILY\fR(7)), CREATE OPERATOR CLASS (\fBCREATE_OPERATOR_CLASS\fR(7)), ALTER OPERATOR CLASS (\fBALTER_OPERATOR_CLASS\fR(7)), DROP OPERATOR CLASS (\fBDROP_OPERATOR_CLASS\fR(7))