Skip to main content
ALTER PARTITION is used to add, modify, reset, or remove replication zones for . It is combined with the CONFIGURE ZONE subcommand. To view details about existing replication zones, use . For more information about replication zones, see . For instructions showing how to troubleshoot replication zones that may be misconfigured, see . 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.

Synopsis

alter_zone_partition syntax diagram

Required privileges

The user must have the privilege on the table.

Parameters

Variables

If a value is not set, new zone configurations will inherit their values from their parent zone (e.g., a partition zone inherits from the table zone), which is not necessarily default.If a variable is set to COPY FROM PARENT (e.g., range_max_bytes = COPY FROM PARENT), the variable will copy its value from its parent . The COPY FROM PARENT value is a convenient shortcut to use so you do not have to look up the parent’s current value. For example, the range_max_bytes and range_min_bytes variables must be set together, so when editing one value, you can use COPY FROM PARENT for the other. Note that if the variable in the parent replication zone is changed after the child replication zone is copied, the change will not be reflected in the child zone.

Examples

Setup

The following examples use MovR, a fictional vehicle-sharing application, to demonstrate CockroachDB SQL statements. For more information about the MovR example application and dataset, see . To follow along, run with the --geo-partitioned-replicas flag. This command opens an interactive SQL shell to a temporary, 9-node in-memory cluster with the movr database.

Create a replication zone for a partition

Once , to control replication for a partition, use ALTER PARTITION <partition> OF INDEX <table@index> CONFIGURE ZONE:
To define replication zones for identically named partitions of a table and its secondary indexes, you can use the @* syntax to save several steps:
To view the zone configuration for a partition, use SHOW ZONE CONFIGURATION FROM PARTITION <partition> OF INDEX <table@index>:
You can also use the statement or statements to view details about all of the replication zones defined for the partitions of a table and its secondary indexes.
For instructions showing how to troubleshoot replication zones that may be misconfigured, see .

See also