CREATE OPERATOR

An SQL command for creating an operator

CREATE OPERATOR is a DDL command for creating an operator.

CREATE OPERATOR has always been present in PostgreSQL.

Change history

Examples

Basic usage example for CREATE OPERATOR, here basically reimplementing the + operator:

postgres=# CREATE OPERATOR +@+ (
             PROCEDURE = numeric_add,
             LEFTARG = numeric,
             RIGHTARG = numeric);
CREATE OPERATOR

postgres=# \do
                                      List of operators
 Schema | Name | Left arg type | Right arg type | Result type |         Description          
--------+------+---------------+----------------+-------------+------------------------------
 public | +@+  | numeric       | numeric        | numeric     | implementation of + operator

postgres=# SELECT 1 +@+ 1;
 ?column? 
----------
        2
(1 row)

Categories

DDL, Operators, SQL command

See also

CREATE OPERATOR, DROP OPERATOR, CREATE OPERATOR CLASS, CREATE OPERATOR FAMILY