In the object hierarchy of every schema are Operators. You can add operators by selecting CREATE OPERATOR from the Operators context menu. Once an operator has been created, it can be commented on and dropped. This section describes how to create, comment on, and drop an operator with Administrator.
For more information on operators, refer to Operators under the Extending SQL chapter of the PostgreSQL 7.3 Administrator's Guide.
When creating an operator, you must set the Name and Procedure parameters.
The Name is the name of the new operator. The Procedure is the function used to implement this operator. This corresponds to the func_name parameter of the CREATE OPERATOR command, and only functions already defined in the database may be chosen.
![]() | Note |
|---|---|
Whether an operator is unary or binary is determined by the number of arguments to the function:
|
The remainder of the CREATE OPERATOR parameters are optional. For information on these parameters, see CREATE OPERATOR in the PostgreSQL 7.3 Reference Manual.
This example describes how to define a new operator called @$.
An operator class is an object under a schema, so to create an operator, first expand the database under which you wish to create the operator (click the [O-] beside the database name) and then expand the public schema.
Right-click on Operators and select CREATE OPERATOR. The CREATE OPERATOR dialog appears.
You will create an operator named @$, which will be a left unary operator that does exactly what the function get_amount_by_customer does. If you have dropped that function, please re-create it now.
The first field is for the name of the operator. Type: @$
From the Procedure drop-down list, select: get_amount_by_customer(pg_catalog.int4)
As the Left Hand Argument, select: int4
As this is a left unary operator, you do not need to enter anything for the Right Hand Argument. (Had this been a binary operator, a Right Hand Argument would have been required.) You may also leave all of the optional parameters for this operator blank.
Click OK to define the new operator.
Note that the operator @$(LEFT = int4)->numeric has been added under the Operators node in the Tree View.
Administrator also enables you to perform the following operations on existing operators:
PostgreSQL allows commenting on operator, which makes them easier to identify. To comment on an operator, right-click on it and select COMMENT. A dialog asks for the comment. If there is already a comment on the operator, this comment is displayed. Type the new comment in the edit box and click OK to save it.
To drop an operator, right-click on it and select either DROP RESTRICT or DROP CASCADE (on PostgreSQL 7.3 backends). DROP RESTRICT will not drop the operator if there are any dependent operators. DROP CASCADE automatically drops the operator and all objects that depend on it.
If Preferences => Ask For Confirmations is enabled, you are asked to confirm that you want the operator dropped (and all the dependent operators in case of a DROP CASCADE); if it is disabled, the operator is dropped immediately (along with its dependent operators if DROP CASCADE was selected). This action cannot be undone.