DROP OPERATOR CLASS removes an operator class.
Synopsis
DROP OPERATOR CLASS [ IF EXISTS ] name USING index_method [ CASCADE | RESTRICT ]Description
DROP OPERATOR CLASS removes an existing operator class. You must be the owner of the operator class to execute this command.
The command does not drop any operators or functions referenced by the class. If any indexes depend on the operator class, add CASCADE to drop them along with the class.
Parameters
| Parameter | Description |
|---|---|
IF EXISTS | Do not throw an error if the operator class does not exist. A notice is issued instead. |
name | The name (optionally schema-qualified) of an existing operator class. |
index_method | The name of the index access method the operator class is for. |
CASCADE | Automatically drop objects that depend on the operator class (such as indexes), and in turn all objects that depend on those objects. |
RESTRICT | Refuse to drop the operator class if any objects depend on it. This is the default. |
Usage notes
DROP OPERATOR CLASS does not drop the operator family that contains the class, even if nothing else remains in the family. This applies even when the family was implicitly created by CREATE OPERATOR CLASS. An empty operator family is harmless, but to keep things tidy, remove it with DROP OPERATOR FAMILY. Alternatively, use DROP OPERATOR FAMILY directly instead of DROP OPERATOR CLASS.
Examples
Remove the B-tree operator class widget_ops:
DROP OPERATOR CLASS widget_ops USING btree;This command will not succeed if there are any existing indexes that use the operator class. Add CASCADE to drop such indexes along with the operator class:
DROP OPERATOR CLASS widget_ops USING btree CASCADE;