1<!--
2doc/src/sgml/ref/alter_operator.sgml
3PostgreSQL documentation
4-->
5
6<refentry id="sql-alteroperator">
7 <indexterm zone="sql-alteroperator">
8  <primary>ALTER OPERATOR</primary>
9 </indexterm>
10
11 <refmeta>
12  <refentrytitle>ALTER OPERATOR</refentrytitle>
13  <manvolnum>7</manvolnum>
14  <refmiscinfo>SQL - Language Statements</refmiscinfo>
15 </refmeta>
16
17 <refnamediv>
18  <refname>ALTER OPERATOR</refname>
19  <refpurpose>change the definition of an operator</refpurpose>
20 </refnamediv>
21
22 <refsynopsisdiv>
23<synopsis>
24ALTER OPERATOR <replaceable>name</replaceable> ( { <replaceable>left_type</replaceable> | NONE } , { <replaceable>right_type</replaceable> | NONE } )
25    OWNER TO { <replaceable>new_owner</replaceable> | CURRENT_USER | SESSION_USER }
26
27ALTER OPERATOR <replaceable>name</replaceable> ( { <replaceable>left_type</replaceable> | NONE } , { <replaceable>right_type</replaceable> | NONE } )
28    SET SCHEMA <replaceable>new_schema</replaceable>
29
30ALTER OPERATOR <replaceable>name</replaceable> ( { <replaceable>left_type</replaceable> | NONE } , { <replaceable>right_type</replaceable> | NONE } )
31    SET ( {  RESTRICT = { <replaceable class="parameter">res_proc</replaceable> | NONE }
32           | JOIN = { <replaceable class="parameter">join_proc</replaceable> | NONE }
33         } [, ... ] )
34</synopsis>
35 </refsynopsisdiv>
36
37 <refsect1>
38  <title>Description</title>
39
40  <para>
41   <command>ALTER OPERATOR</command> changes the definition of
42   an operator.
43  </para>
44
45  <para>
46   You must own the operator to use <command>ALTER OPERATOR</command>.
47   To alter the owner, you must also be a direct or indirect member of the new
48   owning role, and that role must have <literal>CREATE</literal> privilege on
49   the operator's schema.  (These restrictions enforce that altering the owner
50   doesn't do anything you couldn't do by dropping and recreating the operator.
51   However, a superuser can alter ownership of any operator anyway.)
52  </para>
53 </refsect1>
54
55 <refsect1>
56  <title>Parameters</title>
57
58  <variablelist>
59   <varlistentry>
60    <term><replaceable class="parameter">name</replaceable></term>
61    <listitem>
62     <para>
63      The name (optionally schema-qualified) of an existing operator.
64     </para>
65    </listitem>
66   </varlistentry>
67
68   <varlistentry>
69    <term><replaceable class="parameter">left_type</replaceable></term>
70    <listitem>
71     <para>
72      The data type of the operator's left operand; write
73      <literal>NONE</literal> if the operator has no left operand.
74     </para>
75    </listitem>
76   </varlistentry>
77
78   <varlistentry>
79    <term><replaceable class="parameter">right_type</replaceable></term>
80    <listitem>
81     <para>
82      The data type of the operator's right operand; write
83      <literal>NONE</literal> if the operator has no right operand.
84     </para>
85    </listitem>
86   </varlistentry>
87
88   <varlistentry>
89    <term><replaceable class="parameter">new_owner</replaceable></term>
90    <listitem>
91     <para>
92      The new owner of the operator.
93     </para>
94    </listitem>
95   </varlistentry>
96
97   <varlistentry>
98    <term><replaceable class="parameter">new_schema</replaceable></term>
99    <listitem>
100     <para>
101      The new schema for the operator.
102     </para>
103    </listitem>
104   </varlistentry>
105
106   <varlistentry>
107     <term><replaceable class="parameter">res_proc</replaceable></term>
108     <listitem>
109       <para>
110         The restriction selectivity estimator function for this operator; write NONE to remove existing selectivity estimator.
111       </para>
112      </listitem>
113   </varlistentry>
114
115   <varlistentry>
116     <term><replaceable class="parameter">join_proc</replaceable></term>
117     <listitem>
118       <para>
119         The join selectivity estimator function for this operator; write NONE to remove existing selectivity estimator.
120       </para>
121     </listitem>
122   </varlistentry>
123
124  </variablelist>
125 </refsect1>
126
127 <refsect1>
128  <title>Examples</title>
129
130  <para>
131   Change the owner of a custom operator <literal>a @@ b</literal> for type <type>text</type>:
132<programlisting>
133ALTER OPERATOR @@ (text, text) OWNER TO joe;
134</programlisting></para>
135
136  <para>
137    Change the restriction and join selectivity estimator functions of a custom operator <literal>a &amp;&amp; b</literal> for type <type>int[]</type>:
138<programlisting>
139ALTER OPERATOR &amp;&amp; (_int4, _int4) SET (RESTRICT = _int_contsel, JOIN = _int_contjoinsel);
140</programlisting></para>
141
142 </refsect1>
143
144 <refsect1>
145  <title>Compatibility</title>
146
147  <para>
148   There is no <command>ALTER OPERATOR</command> statement in
149   the SQL standard.
150  </para>
151 </refsect1>
152
153 <refsect1>
154  <title>See Also</title>
155
156  <simplelist type="inline">
157   <member><xref linkend="sql-createoperator"/></member>
158   <member><xref linkend="sql-dropoperator"/></member>
159  </simplelist>
160 </refsect1>
161</refentry>
162