1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5 >CREATE OPERATOR</TITLE
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
10 HREF="mailto:pgsql-docs@postgresql.org"><LINK
12 TITLE="PostgreSQL 7.4.1 Documentation"
13 HREF="index.html"><LINK
16 HREF="sql-commands.html"><LINK
18 TITLE="CREATE LANGUAGE"
19 HREF="sql-createlanguage.html"><LINK
21 TITLE="CREATE OPERATOR CLASS"
22 HREF="sql-createopclass.html"><LINK
25 HREF="stylesheet.css"><META
27 CONTENT="2003-12-22T03:48:47"></HEAD
33 SUMMARY="Header navigation table"
43 >PostgreSQL 7.4.1 Documentation</TH
51 HREF="sql-createlanguage.html"
60 HREF="sql-createlanguage.html"
73 HREF="sql-createopclass.html"
81 HREF="sql-createopclass.html"
92 NAME="SQL-CREATEOPERATOR"
102 >CREATE OPERATOR -- define a new operator</DIV
107 CLASS="REFSYNOPSISDIV"
115 >CREATE OPERATOR <VAR
126 > ] [, RIGHTARG = <VAR
133 > ] [, NEGATOR = <VAR
144 [, HASHES ] [, MERGES ]
157 >greater_than_op</VAR
172 > defines a new operator,
177 defines an operator becomes its owner. If a schema name is given
178 then the operator is created in the specified schema. Otherwise it
179 is created in the current schema.
182 > The operator name is a sequence of up to <TT
186 (63 by default) characters from the following list:
188 CLASS="LITERALLAYOUT"
189 >+ - * / < > = ~ ! @ # % ^ & | ` ?</P
192 There are a few restrictions on your choice of name:
204 > cannot appear anywhere in an operator name,
205 since they will be taken as the start of a comment.
210 > A multicharacter operator name cannot end in <TT
218 unless the name also contains at least one of these characters:
220 CLASS="LITERALLAYOUT"
221 >~ ! @ # % ^ & | ` ?</P
226 > is an allowed operator name,
231 This restriction allows <SPAN
235 parse SQL-compliant commands without requiring spaces between tokens.
249 > on input, so these two names are always
253 > At least one of <TT
259 > must be defined. For
260 binary operators, both must be defined. For right unary
264 > should be defined, while for left
265 unary operators only <TT
275 procedure must have been previously defined using <TT
279 > and must be defined to accept the correct number
280 of arguments (either one or two) of the indicated types.
283 > The other clauses specify optional operator optimization clauses.
284 Their meaning is detailed in <A
309 > The name of the operator to be defined. See above for allowable
310 characters. The name may be schema-qualified, for example
313 >CREATE OPERATOR myschema.+ (...)</TT
315 the operator is created in the current schema. Two operators
316 in the same schema can have the same name if they operate on
317 different data types. This is called
331 > The function used to implement this operator.
341 > The type of the left-hand argument of the operator, if any.
342 This option would be omitted for a left-unary operator.
352 > The type of the right-hand argument of the operator, if any.
353 This option would be omitted for a right-unary operator.
363 > The commutator of this operator.
373 > The negator of this operator.
383 > The restriction selectivity estimator function for this operator.
393 > The join selectivity estimator function for this operator.
403 > Indicates this operator can support a hash join.
413 > Indicates this operator can support a merge join.
423 > If this operator can support a merge join, the less-than
424 operator that sorts the left-hand data type of this operator.
434 > If this operator can support a merge join, the less-than
435 operator that sorts the right-hand data type of this operator.
445 > If this operator can support a merge join, the less-than
446 operator that compares the input data types of this operator.
452 >greater_than_op</VAR
456 > If this operator can support a merge join, the greater-than
457 operator that compares the input data types of this operator.
463 > To give a schema-qualified operator name in <VAR
466 > or the other optional
467 arguments, use the <TT
470 > syntax, for example
472 CLASS="PROGRAMLISTING"
473 >COMMUTATOR = OPERATOR(myschema.===) ,</PRE
488 > for further information.
494 > to delete user-defined
495 operators from a database.
506 > The following command defines a new operator, area-equality, for
512 CLASS="PROGRAMLISTING"
513 >CREATE OPERATOR === (
516 PROCEDURE = area_equal_procedure,
519 RESTRICT = area_restriction_procedure,
520 JOIN = area_join_procedure,
522 SORT1 = <<<,
524 -- Since sort operators were given, MERGES is implied.
525 -- LTCMP and GTCMP are assumed to be < and > respectively
545 > extension. There are no
546 provisions for user-defined operators in the SQL standard.
554 SUMMARY="Footer navigation table"
565 HREF="sql-createlanguage.html"
583 HREF="sql-createopclass.html"
599 HREF="sql-commands.html"
607 >CREATE OPERATOR CLASS</TD