Contents
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
- PostgreSQL 11
CREATE OPERATOR ... FUNCTION ...
syntax added (commit fd4417e8)
- PostgreSQL 8.3
- options
LTCMP
/GTCMP
andSORT1
/SORT2
removed (commit a78fcfb5)
- options
- PostgreSQL 7.3
- PostgreSQL 7.2
- option
MERGES
removed - options
SORT1
andSORT2
added
- option
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)
References
- PostgreSQL documentation: CREATE OPERATOR