Skip to content

Latest commit

 

History

History
135 lines (89 loc) · 5.55 KB

configure-zone.md

File metadata and controls

135 lines (89 loc) · 5.55 KB
title summary toc
CONFIGURE ZONE
Use the CONFIGURE ZONE statement to add, modify, reset, and remove replication zones.
true

CONFIGURE ZONE is a subcommand of the ALTER DATABASE, ALTER TABLE, ALTER INDEX, ALTER PARTITION, and ALTER RANGE statements and is used to add, modify, reset, or remove replication zones for those objects. To view details about existing replication zones, see SHOW ZONE CONFIGURATIONS.

In CockroachDB, you can use replication zones to control the number and location of replicas for specific sets of data, both when replicas are first added and when they are rebalanced to maintain cluster equilibrium.

{{site.data.alerts.callout_info}} Adding replication zones for secondary indexes and partitions is an enterprise-only feature. {{site.data.alerts.end}}

Synopsis

alter_zone_database_stmt ::=

{% include {{ page.version.version }}/sql/diagrams/alter_zone_database.html %}

alter_zone_table_stmt ::=

{% include {{ page.version.version }}/sql/diagrams/alter_zone_table.html %}

alter_zone_index_stmt ::=

{% include {{ page.version.version }}/sql/diagrams/alter_zone_index.html %}

alter_zone_partition_stmt ::=

{% include {{ page.version.version }}/sql/diagrams/alter_zone_partition.html %}

alter_zone_range_stmt ::=

{% include {{ page.version.version }}/sql/diagrams/alter_zone_range.html %}

Required privileges

If the target is a system range, the system database, or a table in the system database, the user must be an admin. For all other databases and tables, the user must have the CREATE privilege on the target database or table.

{{site.data.alerts.callout_danger}} Required privileges for CONFIGURE ZONE statements in CockroachDB v19.2 may be backward-incompatible for users running scripted statements with restricted permissions in v19.1 and earlier.
To add the necessary permissions, use GRANT <privileges> or GRANT <roles> as a user with an admin role.
For example, to grant a user the admin role, run GRANT admin TO <user>.
To grant the CREATE privilege on a database or table, run GRANT CREATE ON [DATABASE | TABLE] <name> TO <user>. {{site.data.alerts.end}}

Parameters

Parameter | Description -----------+------------- range_name | The name of the system range for which to show replication zone configurations. database_name | The name of the database for which to show replication zone configurations. table_name | The name of the table for which to show replication zone configurations. partition_name | The name of the partition for which to show replication zone configurations. index_name | The name of the index for which to show replication zone configurations. variable | The name of the variable to change. value | The value of the variable to change. DISCARD | Remove a replication zone.

Variables

{% include {{ page.version.version }}/zone-configs/variables.md %}

Viewing schema changes

{% include {{ page.version.version }}/misc/schema-change-view-job.md %}

Examples

{% include {{ page.version.version }}/sql/movr-statements-geo-partitioned-replicas.md %}

Edit a replication zone

{% include copy-clipboard.html %}

> ALTER TABLE users CONFIGURE ZONE USING range_min_bytes = 0, range_max_bytes = 90000, gc.ttlseconds = 89999, num_replicas = 4;
CONFIGURE ZONE 1

Edit the default replication zone

{% include {{ page.version.version }}/zone-configs/edit-the-default-replication-zone.md %}

Create a replication zone for a database

{% include {{ page.version.version }}/zone-configs/create-a-replication-zone-for-a-database.md %}

Create a replication zone for a table

{% include {{ page.version.version }}/zone-configs/create-a-replication-zone-for-a-table.md %}

Create a replication zone for a secondary index

{% include {{ page.version.version }}/zone-configs/create-a-replication-zone-for-a-secondary-index.md %}

Create a replication zone for a partition

{% include {{ page.version.version }}/zone-configs/create-a-replication-zone-for-a-table-partition.md %}

Create a replication zone for a system range

{% include {{ page.version.version }}/zone-configs/create-a-replication-zone-for-a-system-range.md %}

Reset a replication zone

{% include {{ page.version.version }}/zone-configs/reset-a-replication-zone.md %}

Remove a replication zone

{% include {{ page.version.version }}/zone-configs/remove-a-replication-zone.md %}

See also