In the object hierarchy under every schema are Operator Classes. You can add Operator Classes by right-clicking Operator Classes and selecting CREATE OPERATOR CLASS. Once an operator class has been created, it can be dropped. In this section, you will use Administrator to perform these tasks.
At the top of the CREATE OPERATOR CLASS dialog is an entry box for entering the name of the new operator class. This corresponds to the name parameter for the SQL command CREATE OPERATOR CLASS.
Next is a checkbox indicating whether this will be the default operator class for its data type. This corresponds to the DEFAULT flag in the SQL command CREATE OPERATOR CLASS.
Below the Default checkbox is the Data Type combo-box. This enables you to select the data type upon which this operator will be based.
To the right of the Data Type combo-box are radio buttons for selecting the Access Type. These specify the access type to be used for the Operator Class.
Below this are fields that enable you to specify the Operator Class definition. An Operator Class can have multiple definitions. Refer to the PostgreSQL 7.3 Reference Manual for more information.
In the Operator Class Definition field, one of Operators, Functions, or Data Types can be selected for each Operator Class Definition. Select these by clicking on the respective radio buttons, which activate the Strategy/Support number (if applicable) and the combo-box for selection for the object. If the Operator radio button is selected, a checkbox for Recheck on the right also gets activated. Checking this sets the RECHECK flag in the SQL command.
Below the area for the Operator Class Definition is the Add Operator Class Definition button. Once the definition has been filled in, click this button to add the definition to the listbox below. If you wish to remove one or more Definitions from the list box, select them and click the Remove button. You can also move selected definitions up or down by pressing the respective buttons.
In this section you will use the Create Operator Class dialog to create an Operator Class called circle_ops. An Operator Class such as this could be used later if needed, when creating an index over a column with the circle Data Type.
An operator class is an object under a schema, so to create an operator class, first expand the database under which you wish to create the operator class (click the [O-] beside the database name) and then expand the public schema.
Right-click on Operator Classes and select CREATE OPERATOR CLASS. The CREATE OPERATOR CLASS dialog appears.
The first field is the name field, type: circle_ops
Below that is the Default index operator checkbox. Leave this unchecked for this example.
For Data Type, select: circle
To the right is Access Method; select: BTree
For Operator Class Definition; select: Operator
For the Strategy Number, type 1 and from the Operator combo-box, select:
<(LEFT = pg_catalog.circle, RIGHT = pg_catalog.circle) -> pg_catalog.bool |
Click Add Operator Class Definition to add this definition to the list.
Next, enable the Function radio button in the Operator Definition area.
For Support Number, type 1 and for the Function, select:
circle_gt(pg_catalog.circle,pg_catalog.circle) |
Click Add Operator Class Definition to add this definition to the list.
Click OK to create the operator class.
Note that the operator class circle_ops has been added under the Operator Classes node in the Tree View.
Administrator also enables you to perform the following operation on existing Operator Classes:
To drop an Operator Class, right-click on the Operator Class and select either DROP RESTRICT or DROP CASCADE. DROP RESTRICT will not drop the Operator Class if there are any dependent objects. DROP CASCADE automatically drops the Operator Class and all objects that depend on it.
If Preferences => Ask For Confirmations is enabled, you are asked to confirm that you want the Operator Class dropped (and all the dependent objects in case of a DROP CASCADE); if it is disabled, the operator class is dropped immediately (along with its dependent objects if DROP CASCADE was selected). This action cannot be undone.
To learn more about Operator Classes, refer to the PostgreSQL 7.3 Reference Manual.