{"Entry":{"collection":"sql","key":"create-operator-family","name":"CREATE OPERATOR FAMILY","aliases":["createopfamily"],"metadata":{"aliases":["createopfamily"],"changed_in":[],"changes":[{"from":"8.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"8.3"},{"from":"8.4","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description"],"removed":[]},"status":"changed","synopsis":null,"to":"9.0"},{"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"],"removed":[]},"status":"changed","synopsis":null,"to":"10"},{"from":"10","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description"],"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":"13","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description"],"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"}],"content_hash":"3d9f052acade1183579a144a351462291525450cc35b63c559d653074d3e7ae5","editorial":{},"first_version":"8.3","group":"type","imported_at":"2026-09-30T17:43:37.577339+08:00","last_version":"20","name":"CREATE OPERATOR FAMILY","object":"OPERATOR FAMILY","position":3017,"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":"define a new operator family","purpose_zh":"","related":["alter-operator-family","drop-operator-family","create-operator-class","alter-operator-class","drop-operator-class"],"slug":"create-operator-family","source_rev":"a709ab85","synopsis":"CREATE OPERATOR FAMILY name USING index_method","verb":"CREATE"}},"Definition":{"Collection":"sql","Key":"create-operator-family","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"create-operator-family","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-CREATEOPFAMILY","file":"sql-createopfamily.html","lang":"en","name":"CREATE OPERATOR FAMILY","purpose":"define a new operator family","purpose_zh":"","related":["alter-operator-family","drop-operator-family","create-operator-class","alter-operator-class","drop-operator-class"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE OPERATOR FAMILY\u003c/code\u003e creates a new operator family. An operator family defines a collection of related operator classes, and perhaps some additional operators and support functions that are compatible with these operator classes but not essential for the functioning of any individual index. (Operators and functions that are essential to indexes should be grouped within the relevant operator class, rather than being \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eloose\u003c/span\u003e”\u003c/span\u003e in the operator family. Typically, single-data-type operators are bound to operator classes, while cross-data-type operators can be loose in an operator family containing operator classes for both data types.)\u003c/p\u003e\u003cp\u003eThe new operator family is initially empty. It should be populated by issuing subsequent \u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e commands to add contained operator classes, and optionally \u003ccode class=\"command\"\u003eALTER OPERATOR FAMILY\u003c/code\u003e commands to add \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eloose\u003c/span\u003e”\u003c/span\u003e operators and their corresponding support functions.\u003c/p\u003e\u003cp\u003eIf a schema name is given then the operator family is created in the specified schema. Otherwise it is created in the current schema. Two operator families 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 family becomes its owner. Presently, the creating user must be a superuser. (This restriction is made because an erroneous operator family definition could confuse or even crash the server.)\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 family to be created. The name can be schema-qualified.\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\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE OPERATOR FAMILY\u003c/code\u003e is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extension. There is no \u003ccode class=\"command\"\u003eCREATE 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/alter-operator-family/?v=18\" title=\"ALTER OPERATOR FAMILY\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER 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":"CREATE 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","synopsis_text":"CREATE OPERATOR FAMILY name USING index_method"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"create-operator-family","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"CREATE OPERATOR FAMILY","Summary":"定义一个新的操作符族","BodyHTML":"\u003cpre\u003eCREATE OPERATOR FAMILY name USING index_method\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCREATE OPERATOR FAMILY\u003c/code\u003e创建一个新的操作符族。操作符族定义了一组相关的操作符类，以及可能还有一些与这些操作符类兼容、但对任何单个索引的正常工作都不是必需的额外操作符和支持函数。（那些对索引必不可少的操作符和函数应归入相应的操作符类，而不是作为操作符族中的\u003cspan\u003e“\u003cspan\u003e松散\u003c/span\u003e”\u003c/span\u003e成员。通常，单一数据类型的操作符属于操作符类，而跨数据类型的操作符则可以作为操作符族中的松散成员，该操作符族包含这两种数据类型对应的操作符类。）\u003c/p\u003e\u003cp\u003e新的操作符族最初是空的。应当通过随后发出的 \u003ccode\u003eCREATE OPERATOR CLASS\u003c/code\u003e命令向其中添加所包含的操作符类，并可选择通过 \u003ccode\u003eALTER OPERATOR FAMILY\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更多信息请参见\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\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCREATE OPERATOR FAMILY\u003c/code\u003e是一种 \u003cspan\u003ePostgreSQL\u003c/span\u003e扩展。SQL 标准中没有 \u003ccode\u003eCREATE OPERATOR FAMILY\u003c/code\u003e语句。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan\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, \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":"237e98a951bf171757bb97f7d8eef240705d92210a3d1ad9189a5bf71bc32d59","Payload":{"purpose_zh":"定义一个新的操作符族","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE OPERATOR FAMILY\u003c/code\u003e创建一个新的操作符族。操作符族定义了一组相关的操作符类，以及可能还有一些与这些操作符类兼容、但对任何单个索引的正常工作都不是必需的额外操作符和支持函数。（那些对索引必不可少的操作符和函数应归入相应的操作符类，而不是作为操作符族中的\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e松散\u003c/span\u003e”\u003c/span\u003e成员。通常，单一数据类型的操作符属于操作符类，而跨数据类型的操作符则可以作为操作符族中的松散成员，该操作符族包含这两种数据类型对应的操作符类。）\u003c/p\u003e\u003cp\u003e新的操作符族最初是空的。应当通过随后发出的 \u003ccode class=\"command\"\u003eCREATE OPERATOR CLASS\u003c/code\u003e命令向其中添加所包含的操作符类，并可选择通过 \u003ccode class=\"command\"\u003eALTER OPERATOR FAMILY\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更多信息请参见\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\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"参数"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE OPERATOR FAMILY\u003c/code\u003e是一种 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e扩展。SQL 标准中没有 \u003ccode class=\"command\"\u003eCREATE OPERATOR FAMILY\u003c/code\u003e语句。\u003c/p\u003e","key":"compatibility","title":"兼容性"},{"html":"\u003cspan class=\"simplelist\"\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, \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":"CREATE 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","synopsis_text":"CREATE OPERATOR FAMILY name USING index_method"}},"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}
