Home Explore Blog CI



postgresql

1st chunk of `doc/src/sgml/ref/alter_opfamily.sgml`
51598fb779f85d3c623f907ad5b994ac988e820536bbcde40000000100000fa1
<!--
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

Title: ALTER OPERATOR FAMILY
Summary
The SQL command `ALTER OPERATOR FAMILY` is used to modify the definition of an operator family in PostgreSQL. It allows adding or removing operators and support functions, as well as renaming the family or changing its owner or schema. Operators and functions added to a family using this command are considered 'loose' members, indicating compatibility with the family's semantics but not required for any specific index. Superuser privileges are required to use this command.