CREATE OPERATOR CLASS

This page documents the preview version (v2.21). Preview includes features under active development and is for development and testing only. For production, use the stable version (v2024.1). To learn more, see Versioning.

Synopsis

Use the CREATE OPERATOR CLASS statement to create an operator class.

Syntax

create_operator_class ::= CREATE OPERATOR CLASS operator_class_name 
                          [ DEFAULT ] FOR TYPE data_type  USING 
                          index_method AS operator_class_as [ , ... ]

operator_class_as ::= OPERATOR strategy_number operator_name 
                      [ ( operator_signature ) ] [ FOR SEARCH ]
                      | FUNCTION support_number 
                        [ ( op_type [ , ... ] ) ] subprogram_name ( 
                        subprogram_signature )
                      | STORAGE storage_type

create_operator_class

CREATEOPERATORCLASSoperator_class_nameDEFAULTFORTYPEdata_typeUSINGindex_methodAS,operator_class_as

operator_class_as

OPERATORstrategy_numberoperator_name(operator_signature)FORSEARCHFUNCTIONsupport_number(,op_type)subprogram_name(subprogram_signature)STORAGEstorage_type

Semantics

See the semantics of each option in the [PostgreSQL docs][postgresql-docs-create-op-class]. See the semantics of strategy_number and support_number in another page of the [PostgreSQL docs][postgresql-docs-xindex].

Examples

Basic example.

yugabyte=# CREATE OPERATOR CLASS my_op_class
           FOR TYPE int4
           USING btree AS
           OPERATOR 1 <,
           OPERATOR 2 <=;

See also