{"Entry":{"collection":"sql","key":"alter-operator-family","name":"ALTER OPERATOR FAMILY","aliases":["alteropfamily"],"metadata":{"aliases":["alteropfamily"],"changed_in":["8.4","9.0","9.1","9.5","10","14"],"changes":[{"from":"8.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"8.3"},{"from":"8.3","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters","notes"],"removed":[]},"status":"changed","synopsis":{"added":[],"removed":["{  OPERATOR strategy_number operator_name ( op_type, op_type ) [ RECHECK ]"]},"to":"8.4"},{"from":"8.4","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters","notes"],"removed":[]},"status":"changed","synopsis":{"added":["| FUNCTION support_number [ ( op_type [ , op_type ] ) ] function_name ( argument_type [, ...] )","ALTER OPERATOR FAMILY name USING index_method RENAME TO new_name","ALTER OPERATOR FAMILY name USING index_method OWNER TO new_owner"],"removed":["| FUNCTION support_number [ ( op_type [ , op_type ] ) ] funcname ( argument_type [, ...] )","ALTER OPERATOR FAMILY name USING index_method RENAME TO newname","ALTER OPERATOR FAMILY name USING index_method OWNER TO newowner"]},"to":"9.0"},{"from":"9.0","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":{"added":["{  OPERATOR strategy_number operator_name ( op_type, op_type ) [ FOR SEARCH | FOR ORDER BY sort_family_name ]","ALTER OPERATOR FAMILY name USING index_method SET SCHEMA new_schema"],"removed":[]},"to":"9.1"},{"from":"9.1","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters","notes"],"removed":[]},"status":"changed","synopsis":null,"to":"9.2"},{"from":"9.4","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"changed","synopsis":{"added":["OWNER TO { new_owner | CURRENT_USER | SESSION_USER }"],"removed":[]},"to":"9.5"},{"from":"9.5","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description"],"removed":[]},"status":"changed","synopsis":null,"to":"9.6"},{"from":"9.6","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters","notes"],"removed":[]},"status":"changed","synopsis":{"added":["function_name [ ( argument_type [, ...] ) ]"],"removed":[]},"to":"10"},{"from":"10","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters"],"removed":[]},"status":"changed","synopsis":null,"to":"11"},{"from":"11","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description"],"removed":[]},"status":"changed","synopsis":null,"to":"12"},{"from":"12","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":null,"to":"13"},{"from":"13","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters","notes"],"removed":[]},"status":"changed","synopsis":{"added":["OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }"],"removed":[]},"to":"14"},{"from":"16","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description"],"removed":[]},"status":"changed","synopsis":null,"to":"17"},{"from":"17","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["notes"],"removed":[]},"status":"changed","synopsis":null,"to":"18"}],"content_hash":"674a74c15a9000b38c798abd00fb5f195cadf337eaff98650ce60f126b7613d7","editorial":{},"first_version":"8.3","group":"type","imported_at":"2026-09-30T17:43:37.585913+08:00","last_version":"20","name":"ALTER OPERATOR FAMILY","object":"OPERATOR FAMILY","position":3018,"present_in":["8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"purpose":"change the definition of an operator family","purpose_zh":"","related":["create-operator-family","drop-operator-family","create-operator-class","alter-operator-class","drop-operator-class"],"slug":"alter-operator-family","source_rev":"a709ab85","synopsis":"ALTER OPERATOR FAMILY name USING index_method ADD\n{ OPERATOR strategy_number operator_name ( op_type, op_type )\n[ FOR SEARCH | FOR ORDER BY sort_family_name ]\n| FUNCTION support_number [ ( op_type [ , op_type ] ) ]\nfunction_name [ ( argument_type [, ...] ) ]\n} [, ... ]\n\nALTER OPERATOR FAMILY name USING index_method DROP\n{ OPERATOR strategy_number ( op_type [ , op_type ] )\n| FUNCTION support_number ( op_type [ , op_type ] )\n} [, ... ]\n\nALTER OPERATOR FAMILY name USING index_method\nRENAME TO new_name\n\nALTER OPERATOR FAMILY name USING index_method\nOWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }\n\nALTER OPERATOR FAMILY name USING index_method\nSET SCHEMA new_schema","verb":"ALTER"}},"Definition":{"Collection":"sql","Key":"alter-operator-family","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"alter-operator-family","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-ALTEROPFAMILY","file":"sql-alteropfamily.html","lang":"en","name":"ALTER OPERATOR FAMILY","purpose":"change the definition of an operator family","purpose_zh":"","related":["create-operator-family","drop-operator-family","create-operator-class","alter-operator-class","drop-operator-class"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eALTER OPERATOR FAMILY\u003c/code\u003e 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.\u003c/p\u003e\u003cp\u003eWhen operators and support functions are added to a family with \u003ccode class=\"command\"\u003eALTER OPERATOR FAMILY\u003c/code\u003e, they are not part of any specific operator class within the family, but are just \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eloose\u003c/span\u003e”\u003c/span\u003e 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 \u003ca href=\"/docs/18/sql-createopclass.html\" title=\"CREATE OPERATOR CLASS\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE OPERATOR CLASS\u003c/span\u003e\u003c/a\u003e.) \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 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.\u003c/p\u003e\u003cp\u003eYou must be a superuser to use \u003ccode class=\"command\"\u003eALTER OPERATOR FAMILY\u003c/code\u003e. (This restriction is made because an erroneous operator family definition could confuse or even crash the server.)\u003c/p\u003e\u003cp\u003e\u003ccode class=\"command\"\u003eALTER OPERATOR FAMILY\u003c/code\u003e 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's responsibility to define a valid operator family.\u003c/p\u003e\u003cp\u003eRefer to \u003ca href=\"/docs/18/xindex.html\" title=\"36.16. Interfacing Extensions to Indexes\"\u003eSection 36.16\u003c/a\u003e for further information.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name (optionally schema-qualified) of an existing operator family.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name of the index method this operator family is for.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003estrategy_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe index method's strategy number for an operator associated with the operator family.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoperator_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name (optionally schema-qualified) of an operator associated with the operator family.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eIn an \u003ccode class=\"literal\"\u003eOPERATOR\u003c/code\u003e clause, the operand data type(s) of the operator, or \u003ccode class=\"literal\"\u003eNONE\u003c/code\u003e to signify a prefix operator. Unlike the comparable syntax in \u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e, the operand data types must always be specified.\u003c/p\u003e\u003cp\u003eIn an \u003ccode class=\"literal\"\u003eADD FUNCTION\u003c/code\u003e 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 \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e since the function's 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.\u003c/p\u003e\u003cp\u003eIn a \u003ccode class=\"literal\"\u003eDROP FUNCTION\u003c/code\u003e clause, the operand data type(s) the function is intended to support must be specified.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esort_family_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name (optionally schema-qualified) of an existing \u003ccode class=\"literal\"\u003ebtree\u003c/code\u003e operator family that describes the sort ordering associated with an ordering operator.\u003c/p\u003e\u003cp\u003eIf neither \u003ccode class=\"literal\"\u003eFOR SEARCH\u003c/code\u003e nor \u003ccode class=\"literal\"\u003eFOR ORDER BY\u003c/code\u003e is specified, \u003ccode class=\"literal\"\u003eFOR SEARCH\u003c/code\u003e is the default.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esupport_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe index method's support function number for a function associated with the operator family.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe 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.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument_type\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe parameter data type(s) of the function.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe new name of the operator family.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_owner\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe new owner of the operator family.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_schema\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe new schema for the operator family.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003eThe \u003ccode class=\"literal\"\u003eOPERATOR\u003c/code\u003e and \u003ccode class=\"literal\"\u003eFUNCTION\u003c/code\u003e clauses can appear in any order.\u003c/p\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eNotice that the \u003ccode class=\"literal\"\u003eDROP\u003c/code\u003e syntax only specifies the \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eslot\u003c/span\u003e”\u003c/span\u003e 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 \u003ccode class=\"literal\"\u003eDROP FUNCTION\u003c/code\u003e 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.\u003c/p\u003e\u003cp\u003eBecause 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.\u003c/p\u003e\u003cp\u003eThe 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.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eThe 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 \u003ccode class=\"type\"\u003eint4\u003c/code\u003e and \u003ccode class=\"type\"\u003eint2\u003c/code\u003e.\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eALTER OPERATOR FAMILY integer_ops USING btree ADD\n\n  -- int4 vs int2\n  OPERATOR 1 \u0026lt; (int4, int2) ,\n  OPERATOR 2 \u0026lt;= (int4, int2) ,\n  OPERATOR 3 = (int4, int2) ,\n  OPERATOR 4 \u0026gt;= (int4, int2) ,\n  OPERATOR 5 \u0026gt; (int4, int2) ,\n  FUNCTION 1 btint42cmp(int4, int2) ,\n\n  -- int2 vs int4\n  OPERATOR 1 \u0026lt; (int2, int4) ,\n  OPERATOR 2 \u0026lt;= (int2, int4) ,\n  OPERATOR 3 = (int2, int4) ,\n  OPERATOR 4 \u0026gt;= (int2, int4) ,\n  OPERATOR 5 \u0026gt; (int2, int4) ,\n  FUNCTION 1 btint24cmp(int2, int4) ;\n\u003c/pre\u003e\u003cp\u003eTo remove these entries again:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eALTER OPERATOR FAMILY integer_ops USING btree DROP\n\n  -- int4 vs int2\n  OPERATOR 1 (int4, int2) ,\n  OPERATOR 2 (int4, int2) ,\n  OPERATOR 3 (int4, int2) ,\n  OPERATOR 4 (int4, int2) ,\n  OPERATOR 5 (int4, int2) ,\n  FUNCTION 1 (int4, int2) ,\n\n  -- int2 vs int4\n  OPERATOR 1 (int2, int4) ,\n  OPERATOR 2 (int2, int4) ,\n  OPERATOR 3 (int2, int4) ,\n  OPERATOR 4 (int2, int4) ,\n  OPERATOR 5 (int2, int4) ,\n  FUNCTION 1 (int2, int4) ;\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003eThere is no \u003ccode class=\"command\"\u003eALTER OPERATOR FAMILY\u003c/code\u003e statement in the SQL standard.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/create-operator-family/?v=18\" title=\"CREATE OPERATOR FAMILY\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE OPERATOR FAMILY\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-operator-family/?v=18\" title=\"DROP OPERATOR FAMILY\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP OPERATOR FAMILY\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-operator-class/?v=18\" title=\"CREATE OPERATOR CLASS\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE OPERATOR CLASS\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/alter-operator-class/?v=18\" title=\"ALTER OPERATOR CLASS\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER OPERATOR CLASS\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-operator-class/?v=18\" title=\"DROP OPERATOR CLASS\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP OPERATOR CLASS\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"ALTER OPERATOR FAMILY \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e USING \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e ADD\n  {  OPERATOR \u003cem class=\"replaceable\"\u003e\u003ccode\u003estrategy_number\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoperator_name\u003c/code\u003e\u003c/em\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e )\n              [ FOR SEARCH | FOR ORDER BY \u003cem class=\"replaceable\"\u003e\u003ccode\u003esort_family_name\u003c/code\u003e\u003c/em\u003e ]\n   | FUNCTION \u003cem class=\"replaceable\"\u003e\u003ccode\u003esupport_number\u003c/code\u003e\u003c/em\u003e [ ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e [ , \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e ] ) ]\n              \u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction_name\u003c/code\u003e\u003c/em\u003e [ ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument_type\u003c/code\u003e\u003c/em\u003e [, ...] ) ]\n  } [, ... ]\n\nALTER OPERATOR FAMILY \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e USING \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e DROP\n  {  OPERATOR \u003cem class=\"replaceable\"\u003e\u003ccode\u003estrategy_number\u003c/code\u003e\u003c/em\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e [ , \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e ] )\n   | FUNCTION \u003cem class=\"replaceable\"\u003e\u003ccode\u003esupport_number\u003c/code\u003e\u003c/em\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e [ , \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e ] )\n  } [, ... ]\n\nALTER OPERATOR FAMILY \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e USING \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e\n    RENAME TO \u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_name\u003c/code\u003e\u003c/em\u003e\n\nALTER OPERATOR FAMILY \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e USING \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e\n    OWNER TO { \u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_owner\u003c/code\u003e\u003c/em\u003e | CURRENT_ROLE | CURRENT_USER | SESSION_USER }\n\nALTER OPERATOR FAMILY \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e USING \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e\n    SET SCHEMA \u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_schema\u003c/code\u003e\u003c/em\u003e","synopsis_text":"ALTER OPERATOR FAMILY name USING index_method ADD\n{ OPERATOR strategy_number operator_name ( op_type, op_type )\n[ FOR SEARCH | FOR ORDER BY sort_family_name ]\n| FUNCTION support_number [ ( op_type [ , op_type ] ) ]\nfunction_name [ ( argument_type [, ...] ) ]\n} [, ... ]\n\nALTER OPERATOR FAMILY name USING index_method DROP\n{ OPERATOR strategy_number ( op_type [ , op_type ] )\n| FUNCTION support_number ( op_type [ , op_type ] )\n} [, ... ]\n\nALTER OPERATOR FAMILY name USING index_method\nRENAME TO new_name\n\nALTER OPERATOR FAMILY name USING index_method\nOWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }\n\nALTER OPERATOR FAMILY name USING index_method\nSET SCHEMA new_schema"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"alter-operator-family","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"ALTER OPERATOR FAMILY","Summary":"更改一个操作符族的定义","BodyHTML":"\u003cpre\u003eALTER OPERATOR FAMILY name USING index_method ADD\n{ OPERATOR strategy_number operator_name ( op_type, op_type )\n[ FOR SEARCH | FOR ORDER BY sort_family_name ]\n| FUNCTION support_number [ ( op_type [ , op_type ] ) ]\nfunction_name [ ( argument_type [, ...] ) ]\n} [, ... ]\n\nALTER OPERATOR FAMILY name USING index_method DROP\n{ OPERATOR strategy_number ( op_type [ , op_type ] )\n| FUNCTION support_number ( op_type [ , op_type ] )\n} [, ... ]\n\nALTER OPERATOR FAMILY name USING index_method\nRENAME TO new_name\n\nALTER OPERATOR FAMILY name USING index_method\nOWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }\n\nALTER OPERATOR FAMILY name USING index_method\nSET SCHEMA new_schema\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eALTER OPERATOR FAMILY\u003c/code\u003e更改一个操作符族的定义。你可以向该族添加操作符和支持函数、从该族中移除它们，或者更改该族的名称或拥有者。\u003c/p\u003e\u003cp\u003e使用\u003ccode\u003eALTER OPERATOR FAMILY\u003c/code\u003e向一个族中添加操作符和支持函数时，它们并不属于该族内任何特定的操作符类，而只是作为该族中的\u003cspan\u003e“\u003cspan\u003e松散\u003c/span\u003e”\u003c/span\u003e成员存在。这表明这些操作符和函数与该族的语义兼容，但并不是任何特定索引正确工作所必需的。（那些确实必需的操作符和函数应当声明为某个操作符类的一部分；参见\u003ca href=\"/docs/18/sql-createopclass.html\" title=\"CREATE OPERATOR CLASS\" rel=\"nofollow\"\u003e\u003cspan\u003eCREATE OPERATOR CLASS\u003c/span\u003e\u003c/a\u003e。）\u003cspan\u003ePostgreSQL\u003c/span\u003e允许随时从一个族中删除松散成员，但如果不删除整个类以及依赖它的任何索引，就不能删除操作符类的成员。通常，单一数据类型的操作符和函数属于操作符类，因为支持该特定数据类型上的索引需要它们，而跨数据类型的操作符和函数则作为该族中的松散成员。\u003c/p\u003e\u003cp\u003e要使用\u003ccode\u003eALTER OPERATOR FAMILY\u003c/code\u003e，你必须是超级用户。（之所以这样限制，是因为错误的操作符族定义可能会使服务器混乱，甚至导致崩溃。）\u003c/p\u003e\u003cp\u003e\u003ccode\u003eALTER OPERATOR FAMILY\u003c/code\u003e目前不会检查操作符族定义是否包括该索引方法所要求的全部操作符和函数，也不会检查这些操作符和函数是否构成一个自洽的集合。定义一个合法的操作符族是用户的责任。\u003c/p\u003e\u003cp\u003e更多信息请参见\u003ca href=\"/docs/18/xindex.html\" rel=\"nofollow\"\u003e第 36.16 节\u003c/a\u003e。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e参数\u003c/h2\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e一个现有操作符族的名称（可以是模式限定的）。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该操作符族所对应的索引方法名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003estrategy_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e与该操作符族关联的操作符的索引方法策略号。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eoperator_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e与该操作符族关联的操作符名称（可以是模式限定的）。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e在\u003ccode\u003eOPERATOR\u003c/code\u003e子句中，表示该操作符的操作数数据类型，或者用\u003ccode\u003eNONE\u003c/code\u003e表示一个前缀操作符。不同于 \u003ccode\u003eCREATE OPERATOR CLASS\u003c/code\u003e中的对应语法，操作数数据类型必须始终显式指定。\u003c/p\u003e\u003cp\u003e在\u003ccode\u003eADD FUNCTION\u003c/code\u003e子句中，如果该函数要支持的操作数数据类型不同于它的输入数据类型，则在此指定。对于 B-树比较函数和 hash 函数，不必指定\u003cem\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e，因为函数的输入数据类型始终就是应使用的正确类型。对于 B-树排序支持函数、B-树等值映像函数，以及 GiST、SP-GiST 和 GIN 操作符类中的所有函数，则必须指定该函数要配合使用的操作数数据类型。\u003c/p\u003e\u003cp\u003e在\u003ccode\u003eDROP FUNCTION\u003c/code\u003e子句中，必须指定该函数意图支持的操作数数据类型。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003esort_family_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e一个现有\u003ccode\u003ebtree\u003c/code\u003e操作符族的名称（可以是模式限定的），它描述与某个排序操作符关联的排序顺序。\u003c/p\u003e\u003cp\u003e如果既没有指定\u003ccode\u003eFOR SEARCH\u003c/code\u003e，也没有指定 \u003ccode\u003eFOR ORDER BY\u003c/code\u003e，则默认值是\u003ccode\u003eFOR SEARCH\u003c/code\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003esupport_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e与该操作符族关联的函数的索引方法支持函数编号。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003efunction_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e作为该操作符族索引方法支持函数的函数名称（可以是模式限定的）。如果没有指定参数列表，则该名称在其模式中必须唯一。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eargument_type\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该函数的参数数据类型。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003enew_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该操作符族的新名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003enew_owner\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该操作符族的新拥有者。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003enew_schema\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该操作符族所在的新模式。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\u003ccode\u003eOPERATOR\u003c/code\u003e和\u003ccode\u003eFUNCTION\u003c/code\u003e子句可以以任何顺序出现。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e注解\u003c/h2\u003e\u003cp\u003e注意，\u003ccode\u003eDROP\u003c/code\u003e语法只通过策略号或支持函数编号以及输入数据类型来指定操作符族中的\u003cspan\u003e“\u003cspan\u003e槽位\u003c/span\u003e”\u003c/span\u003e，不会提及占用该槽位的操作符或函数名称。另外，对于\u003ccode\u003eDROP FUNCTION\u003c/code\u003e，要指定的类型是该函数意图支持的输入数据类型；对于 GiST、SP-GiST 和 GIN 索引，这些类型可能与该函数实际的输入参数类型毫无关系。\u003c/p\u003e\u003cp\u003e因为索引机制在使用函数之前不会检查函数的访问权限，将一个函数或者操作符包括在一个操作符族中相当于在其上授予公共执行权限。这对操作符族中很有用的这类函数来说通常不成问题。\u003c/p\u003e\u003cp\u003e操作符不应该由 SQL 函数定义。SQL 函数很可能会被内联到调用查询中，这会妨碍优化器识别该查询匹配一个索引。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e下列示例命令向一个已经包含数据类型\u003ccode\u003eint4\u003c/code\u003e和\u003ccode\u003eint2\u003c/code\u003e 的 B-树操作符类的操作符族中添加跨数据类型的操作符和支持函数。\u003c/p\u003e\u003cpre\u003eALTER OPERATOR FAMILY integer_ops USING btree ADD\n\n  -- int4 对 int2\n  OPERATOR 1 \u0026lt; (int4, int2) ,\n  OPERATOR 2 \u0026lt;= (int4, int2) ,\n  OPERATOR 3 = (int4, int2) ,\n  OPERATOR 4 \u0026gt;= (int4, int2) ,\n  OPERATOR 5 \u0026gt; (int4, int2) ,\n  FUNCTION 1 btint42cmp(int4, int2) ,\n\n  -- int2 对 int4\n  OPERATOR 1 \u0026lt; (int2, int4) ,\n  OPERATOR 2 \u0026lt;= (int2, int4) ,\n  OPERATOR 3 = (int2, int4) ,\n  OPERATOR 4 \u0026gt;= (int2, int4) ,\n  OPERATOR 5 \u0026gt; (int2, int4) ,\n  FUNCTION 1 btint24cmp(int2, int4) ;\n\u003c/pre\u003e\u003cp\u003e要再次移除这些条目：\u003c/p\u003e\u003cpre\u003eALTER OPERATOR FAMILY integer_ops USING btree DROP\n\n  -- int4 对 int2\n  OPERATOR 1 (int4, int2) ,\n  OPERATOR 2 (int4, int2) ,\n  OPERATOR 3 (int4, int2) ,\n  OPERATOR 4 (int4, int2) ,\n  OPERATOR 5 (int4, int2) ,\n  FUNCTION 1 (int4, int2) ,\n\n  -- int2 对 int4\n  OPERATOR 1 (int2, int4) ,\n  OPERATOR 2 (int2, int4) ,\n  OPERATOR 3 (int2, int4) ,\n  OPERATOR 4 (int2, int4) ,\n  OPERATOR 5 (int2, int4) ,\n  FUNCTION 1 (int2, int4) ;\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e在 SQL 标准中没有 \u003ccode\u003eALTER OPERATOR FAMILY\u003c/code\u003e语句。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/create-operator-family/?v=18\" title=\"CREATE OPERATOR FAMILY\" rel=\"nofollow\"\u003e\u003cspan\u003eCREATE OPERATOR FAMILY\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-operator-family/?v=18\" title=\"DROP OPERATOR FAMILY\" rel=\"nofollow\"\u003e\u003cspan\u003eDROP OPERATOR FAMILY\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-operator-class/?v=18\" title=\"CREATE OPERATOR CLASS\" rel=\"nofollow\"\u003e\u003cspan\u003eCREATE OPERATOR CLASS\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/alter-operator-class/?v=18\" title=\"ALTER OPERATOR CLASS\" rel=\"nofollow\"\u003e\u003cspan\u003eALTER OPERATOR CLASS\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-operator-class/?v=18\" title=\"DROP OPERATOR CLASS\" rel=\"nofollow\"\u003e\u003cspan\u003eDROP OPERATOR CLASS\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"1b5ca64c","ContentHash":"64ae309477e6c7c06827ac3cf29e76a85f83c288011d162c36785b50b44af51a","Payload":{"purpose_zh":"更改一个操作符族的定义","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eALTER OPERATOR FAMILY\u003c/code\u003e更改一个操作符族的定义。你可以向该族添加操作符和支持函数、从该族中移除它们，或者更改该族的名称或拥有者。\u003c/p\u003e\u003cp\u003e使用\u003ccode class=\"command\"\u003eALTER OPERATOR FAMILY\u003c/code\u003e向一个族中添加操作符和支持函数时，它们并不属于该族内任何特定的操作符类，而只是作为该族中的\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e松散\u003c/span\u003e”\u003c/span\u003e成员存在。这表明这些操作符和函数与该族的语义兼容，但并不是任何特定索引正确工作所必需的。（那些确实必需的操作符和函数应当声明为某个操作符类的一部分；参见\u003ca href=\"/docs/18/sql-createopclass.html\" title=\"CREATE OPERATOR CLASS\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE OPERATOR CLASS\u003c/span\u003e\u003c/a\u003e。）\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e允许随时从一个族中删除松散成员，但如果不删除整个类以及依赖它的任何索引，就不能删除操作符类的成员。通常，单一数据类型的操作符和函数属于操作符类，因为支持该特定数据类型上的索引需要它们，而跨数据类型的操作符和函数则作为该族中的松散成员。\u003c/p\u003e\u003cp\u003e要使用\u003ccode class=\"command\"\u003eALTER OPERATOR FAMILY\u003c/code\u003e，你必须是超级用户。（之所以这样限制，是因为错误的操作符族定义可能会使服务器混乱，甚至导致崩溃。）\u003c/p\u003e\u003cp\u003e\u003ccode class=\"command\"\u003eALTER OPERATOR FAMILY\u003c/code\u003e目前不会检查操作符族定义是否包括该索引方法所要求的全部操作符和函数，也不会检查这些操作符和函数是否构成一个自洽的集合。定义一个合法的操作符族是用户的责任。\u003c/p\u003e\u003cp\u003e更多信息请参见\u003ca href=\"/docs/18/xindex.html\" title=\"36.16. 索引扩展接口\"\u003e第 36.16 节\u003c/a\u003e。\u003c/p\u003e","key":"description","title":"描述"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e一个现有操作符族的名称（可以是模式限定的）。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该操作符族所对应的索引方法名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003estrategy_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e与该操作符族关联的操作符的索引方法策略号。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoperator_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e与该操作符族关联的操作符名称（可以是模式限定的）。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e在\u003ccode class=\"literal\"\u003eOPERATOR\u003c/code\u003e子句中，表示该操作符的操作数数据类型，或者用\u003ccode class=\"literal\"\u003eNONE\u003c/code\u003e表示一个前缀操作符。不同于 \u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e中的对应语法，操作数数据类型必须始终显式指定。\u003c/p\u003e\u003cp\u003e在\u003ccode class=\"literal\"\u003eADD FUNCTION\u003c/code\u003e子句中，如果该函数要支持的操作数数据类型不同于它的输入数据类型，则在此指定。对于 B-树比较函数和 hash 函数，不必指定\u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e，因为函数的输入数据类型始终就是应使用的正确类型。对于 B-树排序支持函数、B-树等值映像函数，以及 GiST、SP-GiST 和 GIN 操作符类中的所有函数，则必须指定该函数要配合使用的操作数数据类型。\u003c/p\u003e\u003cp\u003e在\u003ccode class=\"literal\"\u003eDROP FUNCTION\u003c/code\u003e子句中，必须指定该函数意图支持的操作数数据类型。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esort_family_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e一个现有\u003ccode class=\"literal\"\u003ebtree\u003c/code\u003e操作符族的名称（可以是模式限定的），它描述与某个排序操作符关联的排序顺序。\u003c/p\u003e\u003cp\u003e如果既没有指定\u003ccode class=\"literal\"\u003eFOR SEARCH\u003c/code\u003e，也没有指定 \u003ccode class=\"literal\"\u003eFOR ORDER BY\u003c/code\u003e，则默认值是\u003ccode class=\"literal\"\u003eFOR SEARCH\u003c/code\u003e。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esupport_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e与该操作符族关联的函数的索引方法支持函数编号。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e作为该操作符族索引方法支持函数的函数名称（可以是模式限定的）。如果没有指定参数列表，则该名称在其模式中必须唯一。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument_type\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该函数的参数数据类型。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该操作符族的新名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_owner\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该操作符族的新拥有者。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_schema\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e该操作符族所在的新模式。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\u003ccode class=\"literal\"\u003eOPERATOR\u003c/code\u003e和\u003ccode class=\"literal\"\u003eFUNCTION\u003c/code\u003e子句可以以任何顺序出现。\u003c/p\u003e","key":"parameters","title":"参数"},{"html":"\u003cp\u003e注意，\u003ccode class=\"literal\"\u003eDROP\u003c/code\u003e语法只通过策略号或支持函数编号以及输入数据类型来指定操作符族中的\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e槽位\u003c/span\u003e”\u003c/span\u003e，不会提及占用该槽位的操作符或函数名称。另外，对于\u003ccode class=\"literal\"\u003eDROP FUNCTION\u003c/code\u003e，要指定的类型是该函数意图支持的输入数据类型；对于 GiST、SP-GiST 和 GIN 索引，这些类型可能与该函数实际的输入参数类型毫无关系。\u003c/p\u003e\u003cp\u003e因为索引机制在使用函数之前不会检查函数的访问权限，将一个函数或者操作符包括在一个操作符族中相当于在其上授予公共执行权限。这对操作符族中很有用的这类函数来说通常不成问题。\u003c/p\u003e\u003cp\u003e操作符不应该由 SQL 函数定义。SQL 函数很可能会被内联到调用查询中，这会妨碍优化器识别该查询匹配一个索引。\u003c/p\u003e","key":"notes","title":"注解"},{"html":"\u003cp\u003e下列示例命令向一个已经包含数据类型\u003ccode class=\"type\"\u003eint4\u003c/code\u003e和\u003ccode class=\"type\"\u003eint2\u003c/code\u003e 的 B-树操作符类的操作符族中添加跨数据类型的操作符和支持函数。\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eALTER OPERATOR FAMILY integer_ops USING btree ADD\n\n  -- int4 对 int2\n  OPERATOR 1 \u0026lt; (int4, int2) ,\n  OPERATOR 2 \u0026lt;= (int4, int2) ,\n  OPERATOR 3 = (int4, int2) ,\n  OPERATOR 4 \u0026gt;= (int4, int2) ,\n  OPERATOR 5 \u0026gt; (int4, int2) ,\n  FUNCTION 1 btint42cmp(int4, int2) ,\n\n  -- int2 对 int4\n  OPERATOR 1 \u0026lt; (int2, int4) ,\n  OPERATOR 2 \u0026lt;= (int2, int4) ,\n  OPERATOR 3 = (int2, int4) ,\n  OPERATOR 4 \u0026gt;= (int2, int4) ,\n  OPERATOR 5 \u0026gt; (int2, int4) ,\n  FUNCTION 1 btint24cmp(int2, int4) ;\n\u003c/pre\u003e\u003cp\u003e要再次移除这些条目：\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eALTER OPERATOR FAMILY integer_ops USING btree DROP\n\n  -- int4 对 int2\n  OPERATOR 1 (int4, int2) ,\n  OPERATOR 2 (int4, int2) ,\n  OPERATOR 3 (int4, int2) ,\n  OPERATOR 4 (int4, int2) ,\n  OPERATOR 5 (int4, int2) ,\n  FUNCTION 1 (int4, int2) ,\n\n  -- int2 对 int4\n  OPERATOR 1 (int2, int4) ,\n  OPERATOR 2 (int2, int4) ,\n  OPERATOR 3 (int2, int4) ,\n  OPERATOR 4 (int2, int4) ,\n  OPERATOR 5 (int2, int4) ,\n  FUNCTION 1 (int2, int4) ;\n\u003c/pre\u003e","key":"examples","title":"示例"},{"html":"\u003cp\u003e在 SQL 标准中没有 \u003ccode class=\"command\"\u003eALTER OPERATOR FAMILY\u003c/code\u003e语句。\u003c/p\u003e","key":"compatibility","title":"兼容性"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/create-operator-family/?v=18\" title=\"CREATE OPERATOR FAMILY\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE OPERATOR FAMILY\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-operator-family/?v=18\" title=\"DROP OPERATOR FAMILY\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP OPERATOR FAMILY\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-operator-class/?v=18\" title=\"CREATE OPERATOR CLASS\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE OPERATOR CLASS\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/alter-operator-class/?v=18\" title=\"ALTER OPERATOR CLASS\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER OPERATOR CLASS\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-operator-class/?v=18\" title=\"DROP OPERATOR CLASS\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP OPERATOR CLASS\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"另见"}],"sections_same_as":"","synopsis_html":"ALTER OPERATOR FAMILY \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e USING \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e ADD\n  {  OPERATOR \u003cem class=\"replaceable\"\u003e\u003ccode\u003estrategy_number\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoperator_name\u003c/code\u003e\u003c/em\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e )\n              [ FOR SEARCH | FOR ORDER BY \u003cem class=\"replaceable\"\u003e\u003ccode\u003esort_family_name\u003c/code\u003e\u003c/em\u003e ]\n   | FUNCTION \u003cem class=\"replaceable\"\u003e\u003ccode\u003esupport_number\u003c/code\u003e\u003c/em\u003e [ ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e [ , \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e ] ) ]\n              \u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction_name\u003c/code\u003e\u003c/em\u003e [ ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument_type\u003c/code\u003e\u003c/em\u003e [, ...] ) ]\n  } [, ... ]\n\nALTER OPERATOR FAMILY \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e USING \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e DROP\n  {  OPERATOR \u003cem class=\"replaceable\"\u003e\u003ccode\u003estrategy_number\u003c/code\u003e\u003c/em\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e [ , \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e ] )\n   | FUNCTION \u003cem class=\"replaceable\"\u003e\u003ccode\u003esupport_number\u003c/code\u003e\u003c/em\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e [ , \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e ] )\n  } [, ... ]\n\nALTER OPERATOR FAMILY \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e USING \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e\n    RENAME TO \u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_name\u003c/code\u003e\u003c/em\u003e\n\nALTER OPERATOR FAMILY \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e USING \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e\n    OWNER TO { \u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_owner\u003c/code\u003e\u003c/em\u003e | CURRENT_ROLE | CURRENT_USER | SESSION_USER }\n\nALTER OPERATOR FAMILY \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e USING \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e\n    SET SCHEMA \u003cem class=\"replaceable\"\u003e\u003ccode\u003enew_schema\u003c/code\u003e\u003c/em\u003e","synopsis_text":"ALTER OPERATOR FAMILY name USING index_method ADD\n{ OPERATOR strategy_number operator_name ( op_type, op_type )\n[ FOR SEARCH | FOR ORDER BY sort_family_name ]\n| FUNCTION support_number [ ( op_type [ , op_type ] ) ]\nfunction_name [ ( argument_type [, ...] ) ]\n} [, ... ]\n\nALTER OPERATOR FAMILY name USING index_method DROP\n{ OPERATOR strategy_number ( op_type [ , op_type ] )\n| FUNCTION support_number ( op_type [ , op_type ] )\n} [, ... ]\n\nALTER OPERATOR FAMILY name USING index_method\nRENAME TO new_name\n\nALTER OPERATOR FAMILY name USING index_method\nOWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }\n\nALTER OPERATOR FAMILY name USING index_method\nSET SCHEMA new_schema"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
