DROP DOMAIN

Synopsis

Use the DROP DOMAIN statement to remove a domain from the database.

Syntax

  1. drop_domain ::= DROP DOMAIN [ IF EXISTS ] name [ , ... ]
  2. [ CASCADE | RESTRICT ]

drop_domain

DROP DOMAIN - 图1

Semantics

drop_domain

name

Specify the name of the existing domain. An error is raised if the specified domain does not exist (unless IF EXISTS is set). An error is raised if any objects depend on this domain (unless CASCADE is set).

IF EXISTS

Do not throw an error if the domain does not exist.

CASCADE

Automatically drop objects that depend on the domain such as table columns using the domain data type and, in turn, all other objects that depend on those objects.

RESTRICT

Refuse to drop the domain if objects depend on it (default).

Examples

Example 1

  1. yugabyte=# CREATE DOMAIN idx DEFAULT 5 CHECK (VALUE > 0);
  1. yugabyte=# DROP DOMAIN idx;

Example 2

  1. yugabyte=# CREATE DOMAIN idx DEFAULT 5 CHECK (VALUE > 0);
  1. yugabyte=# CREATE TABLE t (k idx primary key);
  1. yugabyte=# DROP DOMAIN idx CASCADE;

See also