DROP TYPE
Synopsis
Use the DROP TYPE
statement to remove a user-defined type from the database.
Syntax
drop_type ::= DROP TYPE [ IF EXISTS ] type_name [ , ... ]
[ CASCADE | RESTRICT ]
drop_type
Semantics
drop_type
type_name
Specify the name of the user-defined type to drop.
Examples
Simple example
yugabyte=# CREATE TYPE feature_struct AS (id INTEGER, name TEXT);
yugabyte=# DROP TYPE feature_struct;
IF EXISTS
example
yugabyte=# DROP TYPE IF EXISTS feature_shell;
CASCADE
example
yugabyte=# CREATE TYPE feature_enum AS ENUM ('one', 'two', 'three');
yugabyte=# CREATE TABLE feature_tab_enum (feature_col feature_enum);
yugabyte=# DROP TYPE feature_tab_enum CASCADE;
RESTRICT
example
yugabyte=# CREATE TYPE feature_range AS RANGE (subtype=INTEGER);
yugabyte=# CREATE TABLE feature_tab_range (feature_col feature_range);
yugabyte=# -- The following should error:
yugabyte=# DROP TYPE feature_range RESTRICT;
yugabyte=# DROP TABLE feature_tab_range;
yugabyte=# DROP TYPE feature_range RESTRICT;
See also
当前内容版权归 YugabyteDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 YugabyteDB .