{"Entry":{"collection":"sql","key":"create-operator-class","name":"CREATE OPERATOR CLASS","aliases":["createopclass"],"metadata":{"aliases":["createopclass"],"changed_in":["7.4","8.3","8.4","9.0","9.1"],"changes":[{"from":"7.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"7.3"},{"from":"7.3","purpose_changed":true,"renamed":null,"sections":{"added":["parameters","examples","see_also"],"changed":["description","compatibility"],"removed":["usage"]},"status":"changed","synopsis":{"added":["CREATE OPERATOR CLASS name [ DEFAULT ] FOR TYPE data_type USING index_method AS","{  OPERATOR strategy_number operator_name [ ( op_type, op_type ) ] [ RECHECK ]","| FUNCTION support_number funcname ( argument_type [, ...] )"],"removed":["CREATE OPERATOR CLASS name [ DEFAULT ] FOR TYPE data_type USING access_method AS","{  OPERATOR strategy_number operator_id [ ( type, type ) ] [ RECHECK ]","| FUNCTION support_number func_name ( parameter_types )"]},"to":"7.4"},{"from":"7.4","purpose_changed":false,"renamed":null,"sections":{"added":["notes"],"changed":["description"],"removed":[]},"status":"changed","synopsis":null,"to":"8.0"},{"from":"8.0","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description"],"removed":[]},"status":"changed","synopsis":null,"to":"8.1"},{"from":"8.1","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters","notes","examples"],"removed":[]},"status":"changed","synopsis":null,"to":"8.2"},{"from":"8.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters","see_also"],"removed":[]},"status":"changed","synopsis":{"added":["USING index_method [ FAMILY family_name ] AS","| FUNCTION support_number [ ( op_type [ , op_type ] ) ] funcname ( argument_type [, ...] )"],"removed":[]},"to":"8.3"},{"from":"8.3","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters","notes","examples"],"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 [, ...] )"],"removed":["| FUNCTION support_number [ ( op_type [ , op_type ] ) ] funcname ( argument_type [, ...] )"]},"to":"9.0"},{"from":"9.0","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters","examples"],"removed":[]},"status":"changed","synopsis":{"added":["{  OPERATOR strategy_number operator_name [ ( op_type, op_type ) ] [ FOR SEARCH | FOR ORDER BY sort_family_name ]"],"removed":[]},"to":"9.1"},{"from":"9.1","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":null,"to":"9.2"},{"from":"9.4","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":null,"to":"9.5"},{"from":"9.5","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","examples"],"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":null,"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":null,"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":"105547bf6bd18774c57baf18089ea9a8dc67ac5a4e906cbfcdcc78a12a1b4732","editorial":{},"first_version":"7.3","group":"type","imported_at":"2026-09-30T17:43:37.548367+08:00","last_version":"20","name":"CREATE OPERATOR CLASS","object":"OPERATOR CLASS","position":3014,"present_in":["7.3","7.4","8.0","8.1","8.2","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":"define a new operator class","purpose_zh":"","related":["alter-operator-class","drop-operator-class","create-operator-family","alter-operator-family"],"slug":"create-operator-class","source_rev":"a709ab85","synopsis":"CREATE OPERATOR CLASS name [ DEFAULT ] FOR TYPE data_type\nUSING index_method [ FAMILY family_name ] AS\n{ OPERATOR strategy_number operator_name [ ( op_type, op_type ) ] [ FOR SEARCH | FOR ORDER BY sort_family_name ]\n| FUNCTION support_number [ ( op_type [ , op_type ] ) ] function_name ( argument_type [, ...] )\n| STORAGE storage_type\n} [, ... ]","verb":"CREATE"}},"Definition":{"Collection":"sql","Key":"create-operator-class","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"create-operator-class","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-CREATEOPCLASS","file":"sql-createopclass.html","lang":"en","name":"CREATE OPERATOR CLASS","purpose":"define a new operator class","purpose_zh":"","related":["alter-operator-class","drop-operator-class","create-operator-family","alter-operator-family"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e creates a new operator class. An operator class defines how a particular data type can be used with an index. The operator class specifies that certain operators will fill particular roles or \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003estrategies\u003c/span\u003e”\u003c/span\u003e for this data type and this index method. The operator class also specifies the support functions to be used by the index method when the operator class is selected for an index column. All the operators and functions used by an operator class must be defined before the operator class can be created.\u003c/p\u003e\u003cp\u003eIf a schema name is given then the operator class is created in the specified schema. Otherwise it is created in the current schema. Two operator classes in the same schema can have the same name only if they are for different index methods.\u003c/p\u003e\u003cp\u003eThe user who defines an operator class becomes its owner. Presently, the creating user must be a superuser. (This restriction is made because an erroneous operator class definition could confuse or even crash the server.)\u003c/p\u003e\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e does not presently check whether the operator class 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 class.\u003c/p\u003e\u003cp\u003eRelated operator classes can be grouped into \u003cem class=\"firstterm\"\u003eoperator families\u003c/em\u003e. To add a new operator class to an existing family, specify the \u003ccode class=\"literal\"\u003eFAMILY\u003c/code\u003e option in \u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e. Without this option, the new class is placed into a family named the same as the new class (creating that family if it doesn't already exist).\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 of the operator class to be created. The name can be schema-qualified.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eDEFAULT\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eIf present, the operator class will become the default operator class for its data type. At most one operator class can be the default for a specific data type and index method.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edata_type\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe column data type that this operator class is for.\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 class is for.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efamily_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name of the existing operator family to add this operator class to. If not specified, a family named the same as the operator class is used (creating it, if it doesn't already exist).\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 class.\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 class.\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. The operand data types can be omitted in the normal case where they are the same as the operator class's data type.\u003c/p\u003e\u003cp\u003eIn a \u003ccode class=\"literal\"\u003eFUNCTION\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) or the class's data type (for B-tree sort support functions, B-tree equal image functions, and all functions in GiST, SP-GiST, GIN and BRIN operator classes). These defaults are correct, and so \u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e need not be specified in \u003ccode class=\"literal\"\u003eFUNCTION\u003c/code\u003e clauses, except for the case of a B-tree sort support function that is meant to support cross-data-type comparisons.\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 class.\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 class.\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\u003estorage_type\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe data type actually stored in the index. Normally this is the same as the column data type, but some index methods (currently GiST, GIN, SP-GiST and BRIN) allow it to be different. The \u003ccode class=\"literal\"\u003eSTORAGE\u003c/code\u003e clause must be omitted unless the index method allows a different type to be used. If the column \u003cem class=\"replaceable\"\u003e\u003ccode\u003edata_type\u003c/code\u003e\u003c/em\u003e is specified as \u003ccode class=\"type\"\u003eanyarray\u003c/code\u003e, the \u003cem class=\"replaceable\"\u003e\u003ccode\u003estorage_type\u003c/code\u003e\u003c/em\u003e can be declared as \u003ccode class=\"type\"\u003eanyelement\u003c/code\u003e to indicate that the index entries are members of the element type belonging to the actual array type that each particular index is created for.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003eThe \u003ccode class=\"literal\"\u003eOPERATOR\u003c/code\u003e, \u003ccode class=\"literal\"\u003eFUNCTION\u003c/code\u003e, and \u003ccode class=\"literal\"\u003eSTORAGE\u003c/code\u003e clauses can appear in any order.\u003c/p\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eBecause the index machinery does not check access permissions on functions before using them, including a function or operator in an operator class 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 class.\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 defines a GiST index operator class for the data type \u003ccode class=\"literal\"\u003e_int4\u003c/code\u003e (array of \u003ccode class=\"type\"\u003eint4\u003c/code\u003e). See the \u003ca href=\"/docs/18/intarray.html\" title=\"F.19. intarray — manipulate arrays of integers\"\u003eintarray\u003c/a\u003e module for the complete example.\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE OPERATOR CLASS gist__int_ops\n    DEFAULT FOR TYPE _int4 USING gist AS\n        OPERATOR        3       \u0026amp;\u0026amp;,\n        OPERATOR        6       = (anyarray, anyarray),\n        OPERATOR        7       @\u0026gt;,\n        OPERATOR        8       \u0026lt;@,\n        OPERATOR        20      @@ (_int4, query_int),\n        FUNCTION        1       g_int_consistent (internal, _int4, smallint, oid, internal),\n        FUNCTION        2       g_int_union (internal, internal),\n        FUNCTION        3       g_int_compress (internal),\n        FUNCTION        4       g_int_decompress (internal),\n        FUNCTION        5       g_int_penalty (internal, internal, internal),\n        FUNCTION        6       g_int_picksplit (internal, internal),\n        FUNCTION        7       g_int_same (_int4, _int4, internal);\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extension. There is no \u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e statement in the SQL standard.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\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, \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/alter-operator-family/?v=18\" title=\"ALTER OPERATOR FAMILY\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER OPERATOR FAMILY\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"CREATE OPERATOR CLASS \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ DEFAULT ] FOR TYPE \u003cem class=\"replaceable\"\u003e\u003ccode\u003edata_type\u003c/code\u003e\u003c/em\u003e\n  USING \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e [ FAMILY \u003cem class=\"replaceable\"\u003e\u003ccode\u003efamily_name\u003c/code\u003e\u003c/em\u003e ] AS\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 ) ] [ 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 ] ) ] \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   | STORAGE \u003cem class=\"replaceable\"\u003e\u003ccode\u003estorage_type\u003c/code\u003e\u003c/em\u003e\n  } [, ... ]","synopsis_text":"CREATE OPERATOR CLASS name [ DEFAULT ] FOR TYPE data_type\nUSING index_method [ FAMILY family_name ] AS\n{ OPERATOR strategy_number operator_name [ ( op_type, op_type ) ] [ FOR SEARCH | FOR ORDER BY sort_family_name ]\n| FUNCTION support_number [ ( op_type [ , op_type ] ) ] function_name ( argument_type [, ...] )\n| STORAGE storage_type\n} [, ... ]"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"create-operator-class","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"CREATE OPERATOR CLASS","Summary":"定义一个新的操作符类","BodyHTML":"\u003cpre\u003eCREATE OPERATOR CLASS name [ DEFAULT ] FOR TYPE data_type\nUSING index_method [ FAMILY family_name ] AS\n{ OPERATOR strategy_number operator_name [ ( op_type, op_type ) ] [ FOR SEARCH | FOR ORDER BY sort_family_name ]\n| FUNCTION support_number [ ( op_type [ , op_type ] ) ] function_name ( argument_type [, ...] )\n| STORAGE storage_type\n} [, ... ]\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCREATE OPERATOR CLASS\u003c/code\u003e创建一个新的操作符类。操作符类定义特定数据类型如何与索引一起使用。它规定某些操作符在该数据类型和该索引方法中承担特定角色或\u003cspan\u003e“\u003cspan\u003e策略\u003c/span\u003e”\u003c/span\u003e。当某个索引列选择了该操作符类时，操作符类还会指定索引方法要使用哪些支持函数。操作符类使用的所有操作符和函数都必须先定义好，然后才能创建该操作符类。\u003c/p\u003e\u003cp\u003e如果给出了一个模式名称，那么该操作符类会被创建在指定模式中。否则，它会被创建在当前模式中。同一模式中的两个操作符类只有在被用于不同的索引方法时才可以具有相同的名称。\u003c/p\u003e\u003cp\u003e定义操作符类的用户将成为其拥有者。目前，创建者必须是超级用户。（之所以有此限制，是因为错误的操作符类定义可能会使服务器混乱，甚至崩溃。）\u003c/p\u003e\u003cp\u003e\u003ccode\u003eCREATE OPERATOR CLASS\u003c/code\u003e当前不会检查操作符类定义是否包括该索引方法所要求的所有操作符和函数，也不会检查这些操作符和函数是否构成一个自洽的集合。定义一个合法的操作符类是用户的责任。\u003c/p\u003e\u003cp\u003e相关的操作符类可以分组为\u003cem\u003e操作符族\u003c/em\u003e。要把一个新的操作符类加入现有操作符族，可以在\u003ccode\u003eCREATE OPERATOR CLASS\u003c/code\u003e中指定\u003ccode\u003eFAMILY\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\u003ccode\u003eDEFAULT\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e如果出现，该操作符类将成为其数据类型的默认操作符类。对于某个特定的数据类型和索引方法，最多只能有一个默认操作符类。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003edata_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\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\u003efamily_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\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表示一个前缀操作符。在通常情况下，如果操作数数据类型与操作符类的数据类型相同，则可以省略操作数数据类型。\u003c/p\u003e\u003cp\u003e在\u003ccode\u003eFUNCTION\u003c/code\u003e子句中，表示该函数意图支持的操作数数据类型；如果它不同于函数的输入数据类型（对于 B-树比较函数和 hash 函数），或者不同于该类的数据类型（对于 B-树排序支持函数、B-树等值映像函数，以及 GiST、SP-GiST、GIN 和 BRIN 操作符类中的所有函数），则需要在这里指定。上述默认值通常都是正确的，因此一般不必在 \u003ccode\u003eFUNCTION\u003c/code\u003e子句中指定\u003cem\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e；唯一的例外是某个 B-树排序支持函数打算支持跨数据类型比较的情形。\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\u003estorage_type\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e实际存储在索引中的数据类型。通常它与列数据类型相同，但是有些索引方法（目前是 GiST、GIN、SP-GiST 和 BRIN）允许它们不同。除非索引方法允许使用不同类型，否则必须省略\u003ccode\u003eSTORAGE\u003c/code\u003e子句。如果列的\u003cem\u003e\u003ccode\u003edata_type\u003c/code\u003e\u003c/em\u003e被指定为\u003ccode\u003eanyarray\u003c/code\u003e，则\u003cem\u003e\u003ccode\u003estorage_type\u003c/code\u003e\u003c/em\u003e可以声明为\u003ccode\u003eanyelement\u003c/code\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和\u003ccode\u003eSTORAGE\u003c/code\u003e 子句可以以任何顺序出现。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e注解\u003c/h2\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\u003e_int4\u003c/code\u003e（\u003ccode\u003eint4\u003c/code\u003e数组）定义了一个 GiST 索引操作符类。完整示例见\u003ca href=\"/docs/18/intarray.html\" rel=\"nofollow\"\u003eintarray\u003c/a\u003e模块。\u003c/p\u003e\u003cpre\u003eCREATE OPERATOR CLASS gist__int_ops\n    DEFAULT FOR TYPE _int4 USING gist AS\n        OPERATOR        3       \u0026amp;\u0026amp;,\n        OPERATOR        6       = (anyarray, anyarray),\n        OPERATOR        7       @\u0026gt;,\n        OPERATOR        8       \u0026lt;@,\n        OPERATOR        20      @@ (_int4, query_int),\n        FUNCTION        1       g_int_consistent (internal, _int4, smallint, oid, internal),\n        FUNCTION        2       g_int_union (internal, internal),\n        FUNCTION        3       g_int_compress (internal),\n        FUNCTION        4       g_int_decompress (internal),\n        FUNCTION        5       g_int_penalty (internal, internal, internal),\n        FUNCTION        6       g_int_picksplit (internal, internal),\n        FUNCTION        7       g_int_same (_int4, _int4, internal);\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCREATE OPERATOR CLASS\u003c/code\u003e是一种 \u003cspan\u003ePostgreSQL\u003c/span\u003e扩展。在 SQL 标准中没有 \u003ccode\u003eCREATE OPERATOR CLASS\u003c/code\u003e语句。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan\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, \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/alter-operator-family/?v=18\" title=\"ALTER OPERATOR FAMILY\" rel=\"nofollow\"\u003e\u003cspan\u003eALTER OPERATOR FAMILY\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"1b5ca64c","ContentHash":"fe2dc1cb828f460139bffb3a59d2407574e21daa131f0feb6a73542ffbda8a52","Payload":{"purpose_zh":"定义一个新的操作符类","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e创建一个新的操作符类。操作符类定义特定数据类型如何与索引一起使用。它规定某些操作符在该数据类型和该索引方法中承担特定角色或\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e策略\u003c/span\u003e”\u003c/span\u003e。当某个索引列选择了该操作符类时，操作符类还会指定索引方法要使用哪些支持函数。操作符类使用的所有操作符和函数都必须先定义好，然后才能创建该操作符类。\u003c/p\u003e\u003cp\u003e如果给出了一个模式名称，那么该操作符类会被创建在指定模式中。否则，它会被创建在当前模式中。同一模式中的两个操作符类只有在被用于不同的索引方法时才可以具有相同的名称。\u003c/p\u003e\u003cp\u003e定义操作符类的用户将成为其拥有者。目前，创建者必须是超级用户。（之所以有此限制，是因为错误的操作符类定义可能会使服务器混乱，甚至崩溃。）\u003c/p\u003e\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e当前不会检查操作符类定义是否包括该索引方法所要求的所有操作符和函数，也不会检查这些操作符和函数是否构成一个自洽的集合。定义一个合法的操作符类是用户的责任。\u003c/p\u003e\u003cp\u003e相关的操作符类可以分组为\u003cem class=\"firstterm\"\u003e操作符族\u003c/em\u003e。要把一个新的操作符类加入现有操作符族，可以在\u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e中指定\u003ccode class=\"literal\"\u003eFAMILY\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\u003ccode class=\"literal\"\u003eDEFAULT\u003c/code\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\u003edata_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\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\u003efamily_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\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表示一个前缀操作符。在通常情况下，如果操作数数据类型与操作符类的数据类型相同，则可以省略操作数数据类型。\u003c/p\u003e\u003cp\u003e在\u003ccode class=\"literal\"\u003eFUNCTION\u003c/code\u003e子句中，表示该函数意图支持的操作数数据类型；如果它不同于函数的输入数据类型（对于 B-树比较函数和 hash 函数），或者不同于该类的数据类型（对于 B-树排序支持函数、B-树等值映像函数，以及 GiST、SP-GiST、GIN 和 BRIN 操作符类中的所有函数），则需要在这里指定。上述默认值通常都是正确的，因此一般不必在 \u003ccode class=\"literal\"\u003eFUNCTION\u003c/code\u003e子句中指定\u003cem class=\"replaceable\"\u003e\u003ccode\u003eop_type\u003c/code\u003e\u003c/em\u003e；唯一的例外是某个 B-树排序支持函数打算支持跨数据类型比较的情形。\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\u003estorage_type\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e实际存储在索引中的数据类型。通常它与列数据类型相同，但是有些索引方法（目前是 GiST、GIN、SP-GiST 和 BRIN）允许它们不同。除非索引方法允许使用不同类型，否则必须省略\u003ccode class=\"literal\"\u003eSTORAGE\u003c/code\u003e子句。如果列的\u003cem class=\"replaceable\"\u003e\u003ccode\u003edata_type\u003c/code\u003e\u003c/em\u003e被指定为\u003ccode class=\"type\"\u003eanyarray\u003c/code\u003e，则\u003cem class=\"replaceable\"\u003e\u003ccode\u003estorage_type\u003c/code\u003e\u003c/em\u003e可以声明为\u003ccode class=\"type\"\u003eanyelement\u003c/code\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和\u003ccode class=\"literal\"\u003eSTORAGE\u003c/code\u003e 子句可以以任何顺序出现。\u003c/p\u003e","key":"parameters","title":"参数"},{"html":"\u003cp\u003e因为索引机制在使用函数之前不会检查函数的访问权限，将一个函数或者操作符包括在一个操作符类中，相当于授予其公共执行权限。对适合放入操作符类的那类函数而言，这通常不是问题。\u003c/p\u003e\u003cp\u003e操作符不应该由 SQL 函数定义。SQL 函数很可能会被内联到调用查询中，这会妨碍优化器识别该查询匹配一个索引。\u003c/p\u003e","key":"notes","title":"注解"},{"html":"\u003cp\u003e下面的示例为数据类型\u003ccode class=\"literal\"\u003e_int4\u003c/code\u003e（\u003ccode class=\"type\"\u003eint4\u003c/code\u003e数组）定义了一个 GiST 索引操作符类。完整示例见\u003ca href=\"/docs/18/intarray.html\" title=\"F.19. intarray — 操作整数数组\"\u003eintarray\u003c/a\u003e模块。\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE OPERATOR CLASS gist__int_ops\n    DEFAULT FOR TYPE _int4 USING gist AS\n        OPERATOR        3       \u0026amp;\u0026amp;,\n        OPERATOR        6       = (anyarray, anyarray),\n        OPERATOR        7       @\u0026gt;,\n        OPERATOR        8       \u0026lt;@,\n        OPERATOR        20      @@ (_int4, query_int),\n        FUNCTION        1       g_int_consistent (internal, _int4, smallint, oid, internal),\n        FUNCTION        2       g_int_union (internal, internal),\n        FUNCTION        3       g_int_compress (internal),\n        FUNCTION        4       g_int_decompress (internal),\n        FUNCTION        5       g_int_penalty (internal, internal, internal),\n        FUNCTION        6       g_int_picksplit (internal, internal),\n        FUNCTION        7       g_int_same (_int4, _int4, internal);\n\u003c/pre\u003e","key":"examples","title":"示例"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e是一种 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e扩展。在 SQL 标准中没有 \u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e语句。\u003c/p\u003e","key":"compatibility","title":"兼容性"},{"html":"\u003cspan class=\"simplelist\"\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, \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/alter-operator-family/?v=18\" title=\"ALTER OPERATOR FAMILY\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER OPERATOR FAMILY\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"另见"}],"sections_same_as":"","synopsis_html":"CREATE OPERATOR CLASS \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ DEFAULT ] FOR TYPE \u003cem class=\"replaceable\"\u003e\u003ccode\u003edata_type\u003c/code\u003e\u003c/em\u003e\n  USING \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_method\u003c/code\u003e\u003c/em\u003e [ FAMILY \u003cem class=\"replaceable\"\u003e\u003ccode\u003efamily_name\u003c/code\u003e\u003c/em\u003e ] AS\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 ) ] [ 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 ] ) ] \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   | STORAGE \u003cem class=\"replaceable\"\u003e\u003ccode\u003estorage_type\u003c/code\u003e\u003c/em\u003e\n  } [, ... ]","synopsis_text":"CREATE OPERATOR CLASS name [ DEFAULT ] FOR TYPE data_type\nUSING index_method [ FAMILY family_name ] AS\n{ OPERATOR strategy_number operator_name [ ( op_type, op_type ) ] [ FOR SEARCH | FOR ORDER BY sort_family_name ]\n| FUNCTION support_number [ ( op_type [ , op_type ] ) ] function_name ( argument_type [, ...] )\n| STORAGE storage_type\n} [, ... ]"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","7.3","7.4","8.0","8.1","8.2","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}
