Imported upstream version 1.5
[manpages-zh.git] / raw / man7 / create_operator_class.7
blobd4ab1c47697b582694005b426d9e01c98933f49d
1 .\\" auto-generated by docbook2man-spec $Revision: 1.1 $
2 .TH "CREATE OPERATOR CLASS" "7" "2003-11-02" "SQL - Language Statements" "SQL Commands"
3 .SH NAME
4 CREATE OPERATOR CLASS \- define a new operator class
6 .SH SYNOPSIS
7 .sp
8 .nf
9 CREATE OPERATOR CLASS \fIname\fR [ DEFAULT ] FOR TYPE \fIdata_type\fR USING \fIindex_method\fR AS
10   {  OPERATOR \fIstrategy_number\fR \fIoperator_name\fR [ ( \fIop_type\fR, \fIop_type\fR ) ] [ RECHECK ]
11    | FUNCTION \fIsupport_number\fR \fIfuncname\fR ( \fIargument_type\fR [, ...] )
12    | STORAGE \fIstorage_type\fR
13   } [, ... ]
14 .sp
15 .fi
16 .SH "DESCRIPTION"
17 .PP
18 \fBCREATE OPERATOR CLASS\fR creates a new operator class.
19 An operator class defines how a particular data type can be used with
20 an index. The operator class specifies that certain operators will fill
21 particular roles or ``strategies'' for this data type and this
22 index method. The operator class also specifies the support procedures to
23 be used by 
24 the index method when the operator class is selected for an
25 index column. All the operators and functions used by an operator
26 class must be defined before the operator class is created.
27 .PP
28 If a schema name is given then the operator class is created in the
29 specified schema. Otherwise it is created in the current schema.
30 Two operator classes in the same schema can have the same name only if they
31 are for different index methods.
32 .PP
33 The user who defines an operator class becomes its owner. Presently,
34 the creating user must be a superuser. (This restriction is made because
35 an erroneous operator class definition could confuse or even crash the
36 server.)
37 .PP
38 \fBCREATE OPERATOR CLASS\fR does not presently check
39 whether the operator class definition includes all the operators and functions
40 required by the index method. It is the user's
41 responsibility to define a valid operator class.
42 .PP
43 Refer to the section called ``Interfacing Extensions to Indexes'' in the documentation for further information.
44 .SH "PARAMETERS"
45 .TP
46 \fB\fIname\fB\fR
47 The name of the operator class to be created. The name may be
48 schema-qualified.
49 .TP
50 \fBDEFAULT\fR
51 If present, the operator class will become the default
52 operator class for its data type. At most one operator class
53 can be the default for a specific data type and index method.
54 .TP
55 \fB\fIdata_type\fB\fR
56 The column data type that this operator class is for.
57 .TP
58 \fB\fIindex_method\fB\fR
59 The name of the index method this operator class is for.
60 .TP
61 \fB\fIstrategy_number\fB\fR
62 The index method's strategy number for an operator
63 associated with the operator class.
64 .TP
65 \fB\fIoperator_name\fB\fR
66 The name (optionally schema-qualified) of an operator associated
67 with the operator class.
68 .TP
69 \fB\fIop_type\fB\fR
70 The operand data type(s) of an operator, or NONE to
71 signify a left-unary or right-unary operator. The operand data
72 types may be omitted in the normal case where they are the same
73 as the operator class's data type.
74 .TP
75 \fBRECHECK\fR
76 If present, the index is ``lossy'' for this operator, and
77 so the rows retrieved using the index must be rechecked to
78 verify that they actually satisfy the qualification clause
79 involving this operator.
80 .TP
81 \fB\fIsupport_number\fB\fR
82 The index method's support procedure number for a
83 function associated with the operator class.
84 .TP
85 \fB\fIfuncname\fB\fR
86 The name (optionally schema-qualified) of a function that is an
87 index method support procedure for the operator class.
88 .TP
89 \fB\fIargument_types\fB\fR
90 The parameter data type(s) of the function.
91 .TP
92 \fB\fIstorage_type\fB\fR
93 The data type actually stored in the index. Normally this is
94 the same as the column data type, but some index methods
95 (only GiST at this writing) allow it to be different. The
96 STORAGE clause must be omitted unless the index
97 method allows a different type to be used.
98 .PP
99 The OPERATOR, FUNCTION, and STORAGE
100 clauses may appear in any order.
102 .SH "EXAMPLES"
104 The following example command defines a GiST index operator class
105 for the data type _int4 (array of \fBint4\fR). See
106 \fIcontrib/intarray/\fR for the complete example.
109 CREATE OPERATOR CLASS gist__int_ops
110     DEFAULT FOR TYPE _int4 USING gist AS
111         OPERATOR        3       &&,
112         OPERATOR        6       =       RECHECK,
113         OPERATOR        7       @,
114         OPERATOR        8       ~,
115         OPERATOR        20      @@ (_int4, query_int),
116         FUNCTION        1       g_int_consistent (internal, _int4, int4),
117         FUNCTION        2       g_int_union (bytea, internal),
118         FUNCTION        3       g_int_compress (internal),
119         FUNCTION        4       g_int_decompress (internal),
120         FUNCTION        5       g_int_penalty (internal, internal, internal),
121         FUNCTION        6       g_int_picksplit (internal, internal),
122         FUNCTION        7       g_int_same (_int4, _int4, internal);
125 .SH "COMPATIBILITY"
127 \fBCREATE OPERATOR CLASS\fR is a
128 PostgreSQL extension. There is no
129 \fBCREATE OPERATOR CLASS\fR statement in the SQL
130 standard.
131 .SH "SEE ALSO"
132 ALTER OPERATOR CLASS [\fBalter_operator_class\fR(7)], DROP OPERATOR CLASS [\fBdrop_operator_class\fR(l)]