create_operator.7
来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· 7 代码 · 共 172 行
7
172 行
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "CREATE OPERATOR" "" "2008-01-03" "SQL - Language Statements" "SQL Commands".SH NAMECREATE OPERATOR \- define a new operator.SH SYNOPSIS.sp.nfCREATE OPERATOR \fIname\fR ( PROCEDURE = \fIfuncname\fR [, LEFTARG = \fIlefttype\fR ] [, RIGHTARG = \fIrighttype\fR ] [, COMMUTATOR = \fIcom_op\fR ] [, NEGATOR = \fIneg_op\fR ] [, RESTRICT = \fIres_proc\fR ] [, JOIN = \fIjoin_proc\fR ] [, HASHES ] [, MERGES ] [, SORT1 = \fIleft_sort_op\fR ] [, SORT2 = \fIright_sort_op\fR ] [, LTCMP = \fIless_than_op\fR ] [, GTCMP = \fIgreater_than_op\fR ]).sp.fi.SH "DESCRIPTION".PP\fBCREATE OPERATOR\fR defines a new operator,\fIname\fR. The user whodefines an operator becomes its owner. If a schema name is giventhen the operator is created in the specified schema. Otherwise itis created in the current schema..PPThe operator name is a sequence of up to \fBNAMEDATALEN\fR-1(63 by default) characters from the following list:.sp.nf+ - * / < > = ~ ! @ # % ^ & | ` ?.sp.fiThere are a few restrictions on your choice of name:.TP 0.2i\(bu-- and /* cannot appear anywhere in an operator name,since they will be taken as the start of a comment..TP 0.2i\(buA multicharacter operator name cannot end in + or-,unless the name also contains at least one of these characters:.sp.nf~ ! @ # % ^ & | ` ?.sp.fiFor example, @- is an allowed operator name,but *- is not.This restriction allows PostgreSQL toparse SQL-compliant commands without requiring spaces between tokens..PP.PPThe operator != is mapped to<> on input, so these two names are alwaysequivalent..PPAt least one of LEFTARG and RIGHTARG must be defined. Forbinary operators, both must be defined. For right unaryoperators, only LEFTARG should be defined, while for leftunary operators only RIGHTARG should be defined..PPThe \fIfuncname\fRprocedure must have been previously defined using \fBCREATEFUNCTION\fR and must be defined to accept the correct numberof arguments (either one or two) of the indicated types..PPThe other clauses specify optional operator optimization clauses.Their meaning is detailed in in the documentation..SH "PARAMETERS".TP\fB\fIname\fB\fRThe name of the operator to be defined. See above for allowablecharacters. The name may be schema-qualified, for exampleCREATE OPERATOR myschema.+ (...). If not, thenthe operator is created in the current schema. Two operatorsin the same schema can have the same name if they operate ondifferent data types. This is called\fIoverloading\fR..TP\fB\fIfuncname\fB\fRThe function used to implement this operator..TP\fB\fIlefttype\fB\fRThe data type of the operator's left operand, if any.This option would be omitted for a left-unary operator..TP\fB\fIrighttype\fB\fRThe data type of the operator's right operand, if any.This option would be omitted for a right-unary operator..TP\fB\fIcom_op\fB\fRThe commutator of this operator..TP\fB\fIneg_op\fB\fRThe negator of this operator..TP\fB\fIres_proc\fB\fRThe restriction selectivity estimator function for this operator..TP\fB\fIjoin_proc\fB\fRThe join selectivity estimator function for this operator..TP\fBHASHES\fRIndicates this operator can support a hash join..TP\fBMERGES\fRIndicates this operator can support a merge join..TP\fB\fIleft_sort_op\fB\fRIf this operator can support a merge join, the less-thanoperator that sorts the left-hand data type of this operator..TP\fB\fIright_sort_op\fB\fRIf this operator can support a merge join, the less-thanoperator that sorts the right-hand data type of this operator..TP\fB\fIless_than_op\fB\fRIf this operator can support a merge join, the less-thanoperator that compares the input data types of this operator..TP\fB\fIgreater_than_op\fB\fRIf this operator can support a merge join, the greater-thanoperator that compares the input data types of this operator..PPTo give a schema-qualified operator name in \fIcom_op\fR or the other optionalarguments, use the OPERATOR() syntax, for example.sp.nfCOMMUTATOR = OPERATOR(myschema.===) ,.sp.fi.PP.SH "NOTES".PPRefer to in the documentation for further information..PPUse DROP OPERATOR [\fBdrop_operator\fR(7)] to delete user-defined operatorsfrom a database. Use ALTER OPERATOR [\fBalter_operator\fR(7)] to modify operators in adatabase..SH "EXAMPLES".PPThe following command defines a new operator, area-equality, forthe data type \fBbox\fR:.sp.nfCREATE OPERATOR === ( LEFTARG = box, RIGHTARG = box, PROCEDURE = area_equal_procedure, COMMUTATOR = ===, NEGATOR = !==, RESTRICT = area_restriction_procedure, JOIN = area_join_procedure, HASHES, SORT1 = <<<, SORT2 = <<< -- Since sort operators were given, MERGES is implied. -- LTCMP and GTCMP are assumed to be < and > respectively);.sp.fi.SH "COMPATIBILITY".PP\fBCREATE OPERATOR\fR is aPostgreSQL extension. There are noprovisions for user-defined operators in the SQL standard..SH "SEE ALSO"ALTER OPERATOR [\fBalter_operator\fR(7)], CREATE OPERATOR CLASS [\fBcreate_operator_class\fR(l)], DROP OPERATOR [\fBdrop_operator\fR(l)]
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?