---
title: "CREATE OPERATOR CLASS"
url: "https://docs.yugabyte.com/stable/api/ysql/the-sql-language/statements/ddl_create_operator_class/"
---

# CREATE OPERATOR CLASS

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

## Synopsis

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

## Syntax

- [![Grammar Icon](/icons/file-lines.svg)Grammar](#grammar-1)
- [![Diagram Icon](/icons/diagram.svg)Diagram](#diagram-1)

```output.ebnf
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

CREATEOPERATORCLASS[operator\_class\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#operator-class-name)DEFAULTFORTYPE[data\_type](/stable/api/ysql/syntax_resources/grammar_diagrams#data-type)USING[index\_method](/stable/api/ysql/syntax_resources/grammar_diagrams#index-method)AS,[operator\_class\_as](#operator-class-as)

#### operator\_class\_as

OPERATOR[strategy\_number](/stable/api/ysql/syntax_resources/grammar_diagrams#strategy-number)[operator\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#operator-name)([operator\_signature](/stable/api/ysql/syntax_resources/grammar_diagrams#operator-signature))FORSEARCHFUNCTION[support\_number](/stable/api/ysql/syntax_resources/grammar_diagrams#support-number)(,[op\_type](/stable/api/ysql/syntax_resources/grammar_diagrams#op-type))[subprogram\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#subprogram-name)([subprogram\_signature](/stable/api/ysql/syntax_resources/grammar_diagrams#subprogram-signature))STORAGE[storage\_type](/stable/api/ysql/syntax_resources/grammar_diagrams#storage-type)

## Semantics

See the semantics of each option in the [PostgreSQL docs](https://www.postgresql.org/docs/15/sql-createopclass.html "PostgreSQL docs"). See the semantics of `strategy_number` and `support_number` in another page of the [PostgreSQL docs](https://www.postgresql.org/docs/15/xindex.html "PostgreSQL docs").

## Examples

Basic example.

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

## See also

- [DROP OPERATOR CLASS](/stable/api/ysql/the-sql-language/statements/ddl_drop_operator_class "DROP OPERATOR CLASS")
