title | summary | toc |
---|---|---|
ADD REGION |
The ADD REGION statement adds a region to a multi-region database. |
true |
New in v21.1: The ALTER DATABASE .. ADD REGION
statement adds a region to a multi-region database.
{{site.data.alerts.callout_info}}
ADD REGION
is a subcommand of ALTER DATABASE
{{site.data.alerts.end}}
{{site.data.alerts.callout_danger}}
In order to add a region with ADD REGION
, you must first set a primary database region. For an example showing how to add a primary region, see Set the primary region.
{{site.data.alerts.end}}
| Parameter | Description |
|-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| database_name
| The database to which you are adding a region. |
| region_name
| The region being added to this database. Allowed values include any region present in SHOW REGIONS FROM CLUSTER
. |
The user must be a member of the admin
or owner roles, or have the CREATE
privilege on the database.
To add the first region, or to set an already-added region as the primary region, use the following statement:
{% include copy-clipboard.html %}
ALTER DATABASE foo PRIMARY REGION "us-east1";
ALTER DATABASE PRIMARY REGION
For more information, see Database regions.
To add another region to a database that already has at least one region, use a statement like the following:
{% include copy-clipboard.html %}
ALTER database foo ADD region "us-east1";
ALTER DATABASE ADD REGION
For more information, see Database regions.
{{site.data.alerts.callout_info}} Only regions that are defined at node startup time can be added to a multi-region database. For more information, see Cluster regions. {{site.data.alerts.end}}
To view the regions associated with a multi-region database, use the following statement:
{% include copy-clipboard.html %}
SHOW REGIONS FROM DATABASE foo;
database | region | primary | zones
-----------+----------+---------+------------------------------------------------
foo | us-east1 | true | {us-east1-b,us-east1-b,us-east1-b,us-east1-b}
(1 row)
For more information, see Database regions.
To drop a region from a multi-region database, use the following statement:
{% include copy-clipboard.html %}
ALTER DATABASE foo DROP REGION "us-east1";
ALTER DATABASE DROP REGION
{{site.data.alerts.callout_danger}} You can only drop the primary region from a multi-region database if it's the last remaining region. After that, the database will no longer be a multi-region database. {{site.data.alerts.end}}
For more information, see Database regions.