<!--
doc/src/sgml/ref/alter_opfamily.sgml
PostgreSQL documentation
-->
<refentry id="sql-alteropfamily">
<indexterm zone="sql-alteropfamily">
<primary>ALTER OPERATOR FAMILY</primary>
</indexterm>
<refmeta>
<refentrytitle>ALTER OPERATOR FAMILY</refentrytitle>
<manvolnum>7</manvolnum>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>ALTER OPERATOR FAMILY</refname>
<refpurpose>change the definition of an operator family</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class="parameter">index_method</replaceable> ADD
{ OPERATOR <replaceable class="parameter">strategy_number</replaceable> <replaceable class="parameter">operator_name</replaceable> ( <replaceable class="parameter">op_type</replaceable>, <replaceable class="parameter">op_type</replaceable> )
[ FOR SEARCH | FOR ORDER BY <replaceable class="parameter">sort_family_name</replaceable> ]
| FUNCTION <replaceable class="parameter">support_number</replaceable> [ ( <replaceable class="parameter">op_type</replaceable> [ , <replaceable class="parameter">op_type</replaceable> ] ) ]
<replaceable class="parameter">function_name</replaceable> [ ( <replaceable class="parameter">argument_type</replaceable> [, ...] ) ]
} [, ... ]
ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class="parameter">index_method</replaceable> DROP
{ OPERATOR <replaceable class="parameter">strategy_number</replaceable> ( <replaceable class="parameter">op_type</replaceable> [ , <replaceable class="parameter">op_type</replaceable> ] )
| FUNCTION <replaceable class="parameter">support_number</replaceable> ( <replaceable class="parameter">op_type</replaceable> [ , <replaceable class="parameter">op_type</replaceable> ] )
} [, ... ]
ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class="parameter">index_method</replaceable>
RENAME TO <replaceable>new_name</replaceable>
ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class="parameter">index_method</replaceable>
OWNER TO { <replaceable>new_owner</replaceable> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class="parameter">index_method</replaceable>
SET SCHEMA <replaceable>new_schema</replaceable>
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>ALTER OPERATOR FAMILY</command> 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's name or owner.
</para>
<para>
When operators and support functions are added to a family with
<command>ALTER OPERATOR FAMILY</command>, they are not part of any
specific operator class within the family, but are just <quote>loose</quote>
within the family. This indicates that these operators and functions
are compatible with the family's 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 <xref linkend="sql-createopclass"/>.)
<productname>PostgreSQL</productname> 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.
</para>
<para>
You must be a superuser to use <command>ALTER OPERATOR FAMILY</command>.
(This restriction is made because an erroneous operator family definition