DROP SECONDARY REGION

On this page Carat arrow pointing down

New in v22.2: The ALTER DATABASE .. DROP SECONDARY REGION statement drops the secondary region (if set) from a multi-region database.

The secondary region is used for failover purposes: if the primary region fails, the secondary region acts as the new primary region.

For more information, see Secondary regions.

Note:

This is an enterprise-only feature. Request a 30-day trial license to try it out.

Note:

DROP SECONDARY REGION is a subcommand of ALTER DATABASE.

Synopsis

ALTER DATABASE database_name DROP SECONDARY REGION IF EXISTS

Parameters

Parameter Description
database_name The database from which you are dropping the secondary region (if set).

Required privileges

To drop a secondary region from a database, you must have one of the following:

Examples

Setup

Only a cluster region specified at node startup can be used as a database region.

To follow along with the examples below, start a demo cluster with the --global flag to simulate a multi-region cluster:

icon/buttons/copy
$ cockroach demo --global --nodes 9

To see the regions available to the databases in the cluster, use a SHOW REGIONS FROM CLUSTER statement:

icon/buttons/copy
SHOW REGIONS FROM CLUSTER;
     region    |  zones
---------------+----------
  europe-west1 | {b,c,d}
  us-east1     | {b,c,d}
  us-west1     | {a,b,c}
(3 rows)

Set the primary region for the movr database:

icon/buttons/copy
ALTER DATABASE movr SET PRIMARY REGION "us-east1";

Add the other regions:

icon/buttons/copy
ALTER DATABASE movr ADD REGION "us-west1";
icon/buttons/copy
ALTER DATABASE movr ADD REGION "europe-west1";

Drop the secondary region

To drop the secondary region from the movr database (that was added in Set the secondary region) use the following statement:

icon/buttons/copy
ALTER DATABASE movr DROP SECONDARY REGION;
ALTER DATABASE DROP SECONDARY REGION

See also


Yes No
On this page

Yes No