create_operator_class.7

来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· 7 代码 · 共 145 行

7
145
字号
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "CREATE OPERATOR CLASS" "" "2008-01-03" "SQL - Language Statements" "SQL Commands".SH NAMECREATE OPERATOR CLASS \- define a new operator class.SH SYNOPSIS.sp.nfCREATE OPERATOR CLASS \fIname\fR [ DEFAULT ] FOR TYPE \fIdata_type\fR USING \fIindex_method\fR AS  {  OPERATOR \fIstrategy_number\fR \fIoperator_name\fR [ ( \fIop_type\fR, \fIop_type\fR ) ] [ RECHECK ]   | FUNCTION \fIsupport_number\fR \fIfuncname\fR ( \fIargument_type\fR [, ...] )   | STORAGE \fIstorage_type\fR  } [, ... ].sp.fi.SH "DESCRIPTION".PP\fBCREATE OPERATOR CLASS\fR creates a new operator class.An operator class defines how a particular data type can be used withan index. The operator class specifies that certain operators will fillparticular roles or ``strategies'' for this data type and thisindex method. The operator class also specifies the support procedures tobe used by the index method when the operator class is selected for anindex column. All the operators and functions used by an operatorclass must be defined before the operator class is created..PPIf a schema name is given then the operator class is created in thespecified schema. Otherwise it is created in the current schema.Two operator classes in the same schema can have the same name only if theyare for different index methods..PPThe user who defines an operator class becomes its owner. Presently,the creating user must be a superuser. (This restriction is made becausean erroneous operator class definition could confuse or even crash theserver.).PP\fBCREATE OPERATOR CLASS\fR does not presently checkwhether the operator class definition includes all the operators andfunctions required by the index method, nor whether the operators andfunctions form a self-consistent set. It is the user'sresponsibility to define a valid operator class..PPRefer to in the documentation for further information..SH "PARAMETERS".TP\fB\fIname\fB\fRThe name of the operator class to be created. The name may beschema-qualified..TP\fBDEFAULT\fRIf present, the operator class will become the defaultoperator class for its data type. At most one operator classcan be the default for a specific data type and index method..TP\fB\fIdata_type\fB\fRThe column data type that this operator class is for..TP\fB\fIindex_method\fB\fRThe name of the index method this operator class is for..TP\fB\fIstrategy_number\fB\fRThe index method's strategy number for an operatorassociated with the operator class..TP\fB\fIoperator_name\fB\fRThe name (optionally schema-qualified) of an operator associatedwith the operator class..TP\fB\fIop_type\fB\fRThe operand data type(s) of an operator, or NONE tosignify a left-unary or right-unary operator. The operand datatypes may be omitted in the normal case where they are the sameas the operator class's data type..TP\fBRECHECK\fRIf present, the index is ``lossy'' for this operator, andso the rows retrieved using the index must be rechecked toverify that they actually satisfy the qualification clauseinvolving this operator..TP\fB\fIsupport_number\fB\fRThe index method's support procedure number for afunction associated with the operator class..TP\fB\fIfuncname\fB\fRThe name (optionally schema-qualified) of a function that is anindex method support procedure for the operator class..TP\fB\fIargument_types\fB\fRThe parameter data type(s) of the function..TP\fB\fIstorage_type\fB\fRThe data type actually stored in the index. Normally this isthe same as the column data type, but some index methods(GIN and GiST for now) allow it to be different. TheSTORAGE clause must be omitted unless the indexmethod allows a different type to be used..PPThe OPERATOR, FUNCTION, and STORAGEclauses may appear in any order..PP.SH "NOTES".PPBecause the index machinery does not check access permissions on functionsbefore using them, including a function or operator in an operator classis tantamount to granting public execute permission on it. This is usuallynot an issue for the sorts of functions that are useful in an operatorclass..PPThe operators should not be defined by SQL functions. A SQL functionis likely to be inlined into the calling query, which will preventthe optimizer from recognizing that the query matches an index..SH "EXAMPLES".PPThe following example command defines a GiST index operator classfor the data type _int4 (array of \fBint4\fR). See\fIcontrib/intarray/\fR for the complete example..sp.nfCREATE OPERATOR CLASS gist__int_ops    DEFAULT FOR TYPE _int4 USING gist AS        OPERATOR        3       &&,        OPERATOR        6       =       RECHECK,        OPERATOR        7       @>,        OPERATOR        8       <@,        OPERATOR        20      @@ (_int4, query_int),        FUNCTION        1       g_int_consistent (internal, _int4, int4),        FUNCTION        2       g_int_union (bytea, internal),        FUNCTION        3       g_int_compress (internal),        FUNCTION        4       g_int_decompress (internal),        FUNCTION        5       g_int_penalty (internal, internal, internal),        FUNCTION        6       g_int_picksplit (internal, internal),        FUNCTION        7       g_int_same (_int4, _int4, internal);.sp.fi.SH "COMPATIBILITY".PP\fBCREATE OPERATOR CLASS\fR is aPostgreSQL extension. There is no\fBCREATE OPERATOR CLASS\fR statement in the SQLstandard..SH "SEE ALSO"ALTER OPERATOR CLASS [\fBalter_operator_class\fR(7)], DROP OPERATOR CLASS [\fBdrop_operator_class\fR(l)]

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?