CREATE OPERATOR CLASS 中文man页面

系统
CREATE OPERATOR CLASS 定义一个新的操作符表。 一个操作符表定义一种特定的数据类型可以如何与一种索引一起使用。 操作符表声明特定的操作符可以为这种数据类型以及这种索引方法填充特定角色或者"策略"。 操作符表还声明索引方法在为一个索引字段选定该操作符表的时候要使用的支持过程。 所有操作符表使用的函数和操作符都必须在创建操作符表之前定义。

NAME

CREATE OPERATOR CLASS - 定义一个新的操作符类

SYNOPSIS

CREATE OPERATOR CLASS name [ DEFAULT ] FOR TYPE data_type USING index_method AS
  {  OPERATOR strategy_number operator_name [ ( op_type, op_type ) ] [ RECHECK ]
   | FUNCTION support_number funcname ( argument_type [, ...] )
   | STORAGE storage_type
  } [, ... ]

DESCRIPTION 描述

CREATE OPERATOR CLASS 定义一个新的操作符表。 一个操作符表定义一种特定的数据类型可以如何与一种索引一起使用。 操作符表声明特定的操作符可以为这种数据类型以及这种索引方法填充特定角色或者"策略"。 操作符表还声明索引方法在为一个索引字段选定该操作符表的时候要使用的支持过程。 所有操作符表使用的函数和操作符都必须在创建操作符表之前定义。


 如果给出了模式名字,那么操作符表就在指定的模式中创建。 否则就在当前模式中创建(在搜索路径前面的那个;参阅 CURRENT_SCHEMA())。 在同一个模式中的两个操作符表可以有同样的名字,但它们必须用于不同的索引方法。


 定义操作符表的用户成为其所有者。目前,创造者必须是超级用户。 (作这样的限制是因为一个有问题的操作符表定义会让服务器困惑,甚至崩溃。)

CREATE OPERATOR CLASS 目前并不检查这个类定义是否包含所有索引方法需要操作符以及函数。 定义一个合法的操作符表是用户的责任。


 参考 ``Interfacing Extensions to Indexes'' 获取更多信息。  

PARAMETERS 参数

name

 将要创建的操作符表的名字。名字可以用模式修饰。
DEFAULT

 如果出现了这个键字,那么该操作符表将成为它的数据类型的缺省操作符表。 对于某个数据类型和访问方式而言,最多可以有一个操作符表是缺省的。
data_type

 这个操作符表处理的字段数据类型。
index_method

 这个操作符表处理的索引访问方式的名字。
strategy_number

 一个操作符和这个操作符表关联的索引访问方式的策略数。
operator_name

 一个和该操作符表关联的操作符的名字(可以用模式修饰)。
op_type

 一个操作符的输入数据类型,或者是 NONE 表示左目或者右目操作符。 通常情况下可以省略输入数据类型,因为这个时候它们和操作符表的数据类型相同。
RECHECK

 如果出现,那么索引对这个操作符是"lossy"(有损耗的), 因此,使用这个索引检索的行必须重新检查,以保证它们真正满足和此操作符相关的条件子句。
support_number

 索引方法对一个与操作符表关联的函数的支持过程数。
funcname

 一个函数的名字(可以有模式修饰),这个函数是索引访问方式对此操作符表的支持过程。
argument_types

 函数的参数数据类型。
storage_type

 实际存储在索引里的数据类型。通常它和字段数据类型相同, 但是一些索引方法(到目前为止只有 GIST)允许它是不同的。 除非索引方法允许使用一种不同的类型,否则必须省略 STORAGE 子句。

OPERATOR,FUNCTION,和 STORAGE 子句可以按照任意顺序出现。

EXAMPLES 例子


 下面的例子命令为数据类型 _int4(int4 的数组)定义了一个 GiST 索引操作符表。 参阅 contrib/intarray/ 获取完整的例子。

CREATE 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);

COMPATIBILITY 兼容性

CREATE OPERATOR CLASS 是一个 PostgreSQL 扩展。 在 SQL 标准中没有 CREATE OPERATOR CLASS。  

SEE ALSO 参见

ALTER OPERATOR CLASS [alter_operator_class(7)], DROP OPERATOR CLASS [drop_operator_class(l)]  

#p#

NAME

CREATE OPERATOR CLASS - define a new operator class

SYNOPSIS

CREATE OPERATOR CLASS name [ DEFAULT ] FOR TYPE data_type USING index_method AS
  {  OPERATOR strategy_number operator_name [ ( op_type, op_type ) ] [ RECHECK ]
   | FUNCTION support_number funcname ( argument_type [, ...] )
   | STORAGE storage_type
  } [, ... ]

DESCRIPTION

CREATE OPERATOR CLASS creates a new operator class. An operator class defines how a particular data type can be used with an index. The operator class specifies that certain operators will fill particular roles or ``strategies'' for this data type and this index method. The operator class also specifies the support procedures to be used by the index method when the operator class is selected for an index column. All the operators and functions used by an operator class must be defined before the operator class is created.

If a schema name is given then the operator class is created in the specified schema. Otherwise it is created in the current schema. Two operator classes in the same schema can have the same name only if they are for different index methods.

The user who defines an operator class becomes its owner. Presently, the creating user must be a superuser. (This restriction is made because an erroneous operator class definition could confuse or even crash the server.)

CREATE OPERATOR CLASS does not presently check whether the operator class definition includes all the operators and functions required by the index method. It is the user's responsibility to define a valid operator class.

Refer to the section called ``Interfacing Extensions to Indexes'' in the documentation for further information.  

PARAMETERS

name
The name of the operator class to be created. The name may be schema-qualified.
DEFAULT
If present, the operator class will become the default operator class for its data type. At most one operator class can be the default for a specific data type and index method.
data_type
The column data type that this operator class is for.
index_method
The name of the index method this operator class is for.
strategy_number
The index method's strategy number for an operator associated with the operator class.
operator_name
The name (optionally schema-qualified) of an operator associated with the operator class.
op_type
The operand data type(s) of an operator, or NONE to signify a left-unary or right-unary operator. The operand data types may be omitted in the normal case where they are the same as the operator class's data type.
RECHECK
If present, the index is ``lossy'' for this operator, and so the rows retrieved using the index must be rechecked to verify that they actually satisfy the qualification clause involving this operator.
support_number
The index method's support procedure number for a function associated with the operator class.
funcname
The name (optionally schema-qualified) of a function that is an index method support procedure for the operator class.
argument_types
The parameter data type(s) of the function.
storage_type
The data type actually stored in the index. Normally this is the same as the column data type, but some index methods (only GiST at this writing) allow it to be different. The STORAGE clause must be omitted unless the index method allows a different type to be used.

The OPERATOR, FUNCTION, and STORAGE clauses may appear in any order.

EXAMPLES

The following example command defines a GiST index operator class for the data type _int4 (array of int4). See contrib/intarray/ for the complete example.

CREATE 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);

COMPATIBILITY

CREATE OPERATOR CLASS is a PostgreSQL extension. There is no CREATE OPERATOR CLASS statement in the SQL standard.  

SEE ALSO

ALTER OPERATOR CLASS [alter_operator_class(7)], DROP OPERATOR CLASS [drop_operator_class(l)]

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-24 11:23:20

CREATE OPER中文man

2011-08-24 14:38:16

DROP OPERAT中文man

2011-08-24 09:36:00

alter_opera中文man

2011-08-24 14:35:33

DROP OPERAT中文man

2011-08-24 10:56:32

CREATE CONV中文man

2011-08-24 13:46:39

CREATE VIEW中文man

2011-08-24 13:43:09

CREATE USER中文man

2011-08-24 10:46:36

CREATE AGGR中文man

2011-08-24 13:29:20

CREATE TABL中文man

2011-08-24 11:15:24

CREATE INDE中文man

2011-08-24 13:36:25

CREATE TRIG中文man

2011-08-24 13:32:56

CREATE TABL中文man

2011-08-24 11:02:11

CREATE DOMA中文man

2011-08-24 11:05:36

CREATE FUNC中文man

2011-08-24 13:39:44

CREATE TYPE中文man

2011-08-24 13:23:10

CREATE SCHE中文man

2011-08-24 10:59:19

CREATE DATA中文man

2011-08-24 11:18:53

CREATE LANG中文man

2011-08-24 11:10:17

CREATE GROU中文man

2011-08-24 11:31:47

CREATE RULE中文man
点赞
收藏

51CTO技术栈公众号