gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
14KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ALTER OPERATOR FAMILY</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="sql-alteropclass.html" title="ALTER OPERATOR CLASS" /><link rel="next" href="sql-alterpolicy.html" title="ALTER POLICY" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">ALTER OPERATOR FAMILY</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-alteropclass.html" title="ALTER OPERATOR CLASS">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-alterpolicy.html" title="ALTER POLICY">Next</a></td></tr></table><hr></hr></div><div class="refentry" id="SQL-ALTEROPFAMILY"><div class="titlepage"></div><a id="id-1.9.3.22.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">ALTER OPERATOR FAMILY</span></h2><p>ALTER OPERATOR FAMILY — change the definition of an operator family</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
  3. ALTER OPERATOR FAMILY <em class="replaceable"><code>name</code></em> USING <em class="replaceable"><code>index_method</code></em> ADD
  4. { OPERATOR <em class="replaceable"><code>strategy_number</code></em> <em class="replaceable"><code>operator_name</code></em> ( <em class="replaceable"><code>op_type</code></em>, <em class="replaceable"><code>op_type</code></em> )
  5. [ FOR SEARCH | FOR ORDER BY <em class="replaceable"><code>sort_family_name</code></em> ]
  6. | FUNCTION <em class="replaceable"><code>support_number</code></em> [ ( <em class="replaceable"><code>op_type</code></em> [ , <em class="replaceable"><code>op_type</code></em> ] ) ]
  7. <em class="replaceable"><code>function_name</code></em> [ ( <em class="replaceable"><code>argument_type</code></em> [, ...] ) ]
  8. } [, ... ]
  9. ALTER OPERATOR FAMILY <em class="replaceable"><code>name</code></em> USING <em class="replaceable"><code>index_method</code></em> DROP
  10. { OPERATOR <em class="replaceable"><code>strategy_number</code></em> ( <em class="replaceable"><code>op_type</code></em> [ , <em class="replaceable"><code>op_type</code></em> ] )
  11. | FUNCTION <em class="replaceable"><code>support_number</code></em> ( <em class="replaceable"><code>op_type</code></em> [ , <em class="replaceable"><code>op_type</code></em> ] )
  12. } [, ... ]
  13. ALTER OPERATOR FAMILY <em class="replaceable"><code>name</code></em> USING <em class="replaceable"><code>index_method</code></em>
  14. RENAME TO <em class="replaceable"><code>new_name</code></em>
  15. ALTER OPERATOR FAMILY <em class="replaceable"><code>name</code></em> USING <em class="replaceable"><code>index_method</code></em>
  16. OWNER TO { <em class="replaceable"><code>new_owner</code></em> | CURRENT_USER | SESSION_USER }
  17. ALTER OPERATOR FAMILY <em class="replaceable"><code>name</code></em> USING <em class="replaceable"><code>index_method</code></em>
  18. SET SCHEMA <em class="replaceable"><code>new_schema</code></em>
  19. </pre></div><div class="refsect1" id="id-1.9.3.22.5"><h2>Description</h2><p>
  20. <code class="command">ALTER OPERATOR FAMILY</code> changes the definition of
  21. an operator family. You can add operators and support functions
  22. to the family, remove them from the family,
  23. or change the family's name or owner.
  24. </p><p>
  25. When operators and support functions are added to a family with
  26. <code class="command">ALTER OPERATOR FAMILY</code>, they are not part of any
  27. specific operator class within the family, but are just <span class="quote">“<span class="quote">loose</span>”</span>
  28. within the family. This indicates that these operators and functions
  29. are compatible with the family's semantics, but are not required for
  30. correct functioning of any specific index. (Operators and functions
  31. that are so required should be declared as part of an operator class,
  32. instead; see <a class="xref" href="sql-createopclass.html" title="CREATE OPERATOR CLASS"><span class="refentrytitle">CREATE OPERATOR CLASS</span></a>.)
  33. <span class="productname">PostgreSQL</span> will allow loose members of a
  34. family to be dropped from the family at any time, but members of an
  35. operator class cannot be dropped without dropping the whole class and
  36. any indexes that depend on it.
  37. Typically, single-data-type operators
  38. and functions are part of operator classes because they are needed to
  39. support an index on that specific data type, while cross-data-type
  40. operators and functions are made loose members of the family.
  41. </p><p>
  42. You must be a superuser to use <code class="command">ALTER OPERATOR FAMILY</code>.
  43. (This restriction is made because an erroneous operator family definition
  44. could confuse or even crash the server.)
  45. </p><p>
  46. <code class="command">ALTER OPERATOR FAMILY</code> does not presently check
  47. whether the operator family definition includes all the operators and
  48. functions required by the index method, nor whether the operators and
  49. functions form a self-consistent set. It is the user's
  50. responsibility to define a valid operator family.
  51. </p><p>
  52. Refer to <a class="xref" href="xindex.html" title="37.16. Interfacing Extensions to Indexes">Section 37.16</a> for further information.
  53. </p></div><div class="refsect1" id="id-1.9.3.22.6"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>name</code></em></span></dt><dd><p>
  54. The name (optionally schema-qualified) of an existing operator
  55. family.
  56. </p></dd><dt><span class="term"><em class="replaceable"><code>index_method</code></em></span></dt><dd><p>
  57. The name of the index method this operator family is for.
  58. </p></dd><dt><span class="term"><em class="replaceable"><code>strategy_number</code></em></span></dt><dd><p>
  59. The index method's strategy number for an operator
  60. associated with the operator family.
  61. </p></dd><dt><span class="term"><em class="replaceable"><code>operator_name</code></em></span></dt><dd><p>
  62. The name (optionally schema-qualified) of an operator associated
  63. with the operator family.
  64. </p></dd><dt><span class="term"><em class="replaceable"><code>op_type</code></em></span></dt><dd><p>
  65. In an <code class="literal">OPERATOR</code> clause,
  66. the operand data type(s) of the operator, or <code class="literal">NONE</code> to
  67. signify a left-unary or right-unary operator. Unlike the comparable
  68. syntax in <code class="command">CREATE OPERATOR CLASS</code>, the operand data types
  69. must always be specified.
  70. </p><p>
  71. In an <code class="literal">ADD FUNCTION</code> clause, the operand data type(s) the
  72. function is intended to support, if different from
  73. the input data type(s) of the function. For B-tree comparison functions
  74. and hash functions it is not necessary to specify <em class="replaceable"><code>op_type</code></em> since the function's input
  75. data type(s) are always the correct ones to use. For B-tree sort
  76. support functions and all functions in GiST, SP-GiST and GIN operator
  77. classes, it is necessary to specify the operand data type(s) the function
  78. is to be used with.
  79. </p><p>
  80. In a <code class="literal">DROP FUNCTION</code> clause, the operand data type(s) the
  81. function is intended to support must be specified.
  82. </p></dd><dt><span class="term"><em class="replaceable"><code>sort_family_name</code></em></span></dt><dd><p>
  83. The name (optionally schema-qualified) of an existing <code class="literal">btree</code> operator
  84. family that describes the sort ordering associated with an ordering
  85. operator.
  86. </p><p>
  87. If neither <code class="literal">FOR SEARCH</code> nor <code class="literal">FOR ORDER BY</code> is
  88. specified, <code class="literal">FOR SEARCH</code> is the default.
  89. </p></dd><dt><span class="term"><em class="replaceable"><code>support_number</code></em></span></dt><dd><p>
  90. The index method's support function number for a
  91. function associated with the operator family.
  92. </p></dd><dt><span class="term"><em class="replaceable"><code>function_name</code></em></span></dt><dd><p>
  93. The name (optionally schema-qualified) of a function that is an index
  94. method support function for the operator family. If no argument list
  95. is specified, the name must be unique in its schema.
  96. </p></dd><dt><span class="term"><em class="replaceable"><code>argument_type</code></em></span></dt><dd><p>
  97. The parameter data type(s) of the function.
  98. </p></dd><dt><span class="term"><em class="replaceable"><code>new_name</code></em></span></dt><dd><p>
  99. The new name of the operator family.
  100. </p></dd><dt><span class="term"><em class="replaceable"><code>new_owner</code></em></span></dt><dd><p>
  101. The new owner of the operator family.
  102. </p></dd><dt><span class="term"><em class="replaceable"><code>new_schema</code></em></span></dt><dd><p>
  103. The new schema for the operator family.
  104. </p></dd></dl></div><p>
  105. The <code class="literal">OPERATOR</code> and <code class="literal">FUNCTION</code>
  106. clauses can appear in any order.
  107. </p></div><div class="refsect1" id="id-1.9.3.22.7"><h2>Notes</h2><p>
  108. Notice that the <code class="literal">DROP</code> syntax only specifies the <span class="quote">“<span class="quote">slot</span>”</span>
  109. in the operator family, by strategy or support number and input data
  110. type(s). The name of the operator or function occupying the slot is not
  111. mentioned. Also, for <code class="literal">DROP FUNCTION</code> the type(s) to specify
  112. are the input data type(s) the function is intended to support; for
  113. GiST, SP-GiST and GIN indexes this might have nothing to do with the actual
  114. input argument types of the function.
  115. </p><p>
  116. Because the index machinery does not check access permissions on functions
  117. before using them, including a function or operator in an operator family
  118. is tantamount to granting public execute permission on it. This is usually
  119. not an issue for the sorts of functions that are useful in an operator
  120. family.
  121. </p><p>
  122. The operators should not be defined by SQL functions. A SQL function
  123. is likely to be inlined into the calling query, which will prevent
  124. the optimizer from recognizing that the query matches an index.
  125. </p><p>
  126. Before <span class="productname">PostgreSQL</span> 8.4, the <code class="literal">OPERATOR</code>
  127. clause could include a <code class="literal">RECHECK</code> option. This is no longer
  128. supported because whether an index operator is <span class="quote">“<span class="quote">lossy</span>”</span> is now
  129. determined on-the-fly at run time. This allows efficient handling of
  130. cases where an operator might or might not be lossy.
  131. </p></div><div class="refsect1" id="id-1.9.3.22.8"><h2>Examples</h2><p>
  132. The following example command adds cross-data-type operators and
  133. support functions to an operator family that already contains B-tree
  134. operator classes for data types <code class="type">int4</code> and <code class="type">int2</code>.
  135. </p><pre class="programlisting">
  136. ALTER OPERATOR FAMILY integer_ops USING btree ADD
  137. -- int4 vs int2
  138. OPERATOR 1 &lt; (int4, int2) ,
  139. OPERATOR 2 &lt;= (int4, int2) ,
  140. OPERATOR 3 = (int4, int2) ,
  141. OPERATOR 4 &gt;= (int4, int2) ,
  142. OPERATOR 5 &gt; (int4, int2) ,
  143. FUNCTION 1 btint42cmp(int4, int2) ,
  144. -- int2 vs int4
  145. OPERATOR 1 &lt; (int2, int4) ,
  146. OPERATOR 2 &lt;= (int2, int4) ,
  147. OPERATOR 3 = (int2, int4) ,
  148. OPERATOR 4 &gt;= (int2, int4) ,
  149. OPERATOR 5 &gt; (int2, int4) ,
  150. FUNCTION 1 btint24cmp(int2, int4) ;
  151. </pre><p>
  152. To remove these entries again:
  153. </p><pre class="programlisting">
  154. ALTER OPERATOR FAMILY integer_ops USING btree DROP
  155. -- int4 vs int2
  156. OPERATOR 1 (int4, int2) ,
  157. OPERATOR 2 (int4, int2) ,
  158. OPERATOR 3 (int4, int2) ,
  159. OPERATOR 4 (int4, int2) ,
  160. OPERATOR 5 (int4, int2) ,
  161. FUNCTION 1 (int4, int2) ,
  162. -- int2 vs int4
  163. OPERATOR 1 (int2, int4) ,
  164. OPERATOR 2 (int2, int4) ,
  165. OPERATOR 3 (int2, int4) ,
  166. OPERATOR 4 (int2, int4) ,
  167. OPERATOR 5 (int2, int4) ,
  168. FUNCTION 1 (int2, int4) ;
  169. </pre></div><div class="refsect1" id="id-1.9.3.22.9"><h2>Compatibility</h2><p>
  170. There is no <code class="command">ALTER OPERATOR FAMILY</code> statement in
  171. the SQL standard.
  172. </p></div><div class="refsect1" id="id-1.9.3.22.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-createopfamily.html" title="CREATE OPERATOR FAMILY"><span class="refentrytitle">CREATE OPERATOR FAMILY</span></a>, <a class="xref" href="sql-dropopfamily.html" title="DROP OPERATOR FAMILY"><span class="refentrytitle">DROP OPERATOR FAMILY</span></a>, <a class="xref" href="sql-createopclass.html" title="CREATE OPERATOR CLASS"><span class="refentrytitle">CREATE OPERATOR CLASS</span></a>, <a class="xref" href="sql-alteropclass.html" title="ALTER OPERATOR CLASS"><span class="refentrytitle">ALTER OPERATOR CLASS</span></a>, <a class="xref" href="sql-dropopclass.html" title="DROP OPERATOR CLASS"><span class="refentrytitle">DROP OPERATOR CLASS</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-alteropclass.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-alterpolicy.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ALTER OPERATOR CLASS </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ALTER POLICY</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1