DROP TYPE

Synopsis

Use the DROP TYPE statement to remove a user-defined type from the database.

Syntax

  1. drop_type ::= DROP TYPE [ IF EXISTS ] type_name [ , ... ]
  2. [ CASCADE | RESTRICT ]

drop_type

DROP TYPE - 图1

Semantics

drop_type

type_name

Specify the name of the user-defined type to drop.

Examples

Simple example

  1. yugabyte=# CREATE TYPE feature_struct AS (id INTEGER, name TEXT);
  2. yugabyte=# DROP TYPE feature_struct;

IF EXISTS example

  1. yugabyte=# DROP TYPE IF EXISTS feature_shell;

CASCADE example

  1. yugabyte=# CREATE TYPE feature_enum AS ENUM ('one', 'two', 'three');
  2. yugabyte=# CREATE TABLE feature_tab_enum (feature_col feature_enum);
  3. yugabyte=# DROP TYPE feature_tab_enum CASCADE;

RESTRICT example

  1. yugabyte=# CREATE TYPE feature_range AS RANGE (subtype=INTEGER);
  2. yugabyte=# CREATE TABLE feature_tab_range (feature_col feature_range);
  3. yugabyte=# -- The following should error:
  4. yugabyte=# DROP TYPE feature_range RESTRICT;
  5. yugabyte=# DROP TABLE feature_tab_range;
  6. yugabyte=# DROP TYPE feature_range RESTRICT;

See also