All Products
Search
Document Center

Tablestore:Update global table configurations

Last Updated:Mar 12, 2026

Update the configurations of physical tables in a global table, such as write permissions and primary-secondary switchover settings, using the Tablestore Java SDK.

Usage notes

Data conflicts occur if multiple replicas are writable in active-passive mode. Change this configuration only when you perform an active-passive switchover.

Update scenarios

  • Active-passive mode: During an active-passive switchover, update a replica in a region to be writable or set it as primary eligible.

  • Multi-active mode: Update a replica in a region to be read-only or writable.

Prerequisites

Initialize a client.

Method

public UpdateGlobalTableResponse updateGlobalTable(UpdateGlobalTableRequest request) throws TableStoreException, ClientException

UpdateGlobalTableRequest parameters

  • globalTableId (Required) String: The ID of the global table.

    Note

    If you do not have the global table ID, call the DescribeTable operation to query the details of a table replica. If the table replica is part of a global table, the response from the DescribeTable operation includes the global table ID.

  • globalTableName (Required) String: The name of the global table. This must match the base table name.

  • phyTable (Required) GlobalTableTypes.UpdatePhyTable: The physical table information to update. This includes the following parameters:

    Important

    To update the configuration, modify at least one of the `writable` or `primaryEligible` properties.

    Name

    Type

    Description

    regionId (Required)

    String

    The ID of the region where the physical table to modify is located.

    instanceName (Required)

    String

    The name of the instance where the physical table to modify is located.

    tableName (Required)

    String

    The name of the physical table to modify.

    writable (Optional)

    Boolean

    Determines whether the configuration is writable.

    primaryEligible (Optional)

    Boolean

    Specifies whether the configuration is set to be primary-eligible for failover in active-passive mode.

    In active-passive mode, write operations are disabled by default for all non-primary tables. During an active-passive switchover, mark the secondary table as primary eligible.

Example

private static void updateGlobalTableExample(SyncClient client) {
    // Construct the configuration of the physical table to update.
    GlobalTableTypes.UpdatePhyTable phyTable = new GlobalTableTypes.UpdatePhyTable(
                // The ID of the region where the replica is located.
                "cn-shanghai",  
                // The name of the instance to which the replica belongs.
                "instance-replica-sh",  
                // The name of the replica table.
                "i-dest-test"
    );
    
    // In active-passive mode during a switchover, modify writable and primaryEligible as needed.
    // In multi-active mode when changing replica readability, modify only writable.
    phyTable.setWritable(true);          // Set this replica to be writable.
    phyTable.setPrimaryEligible(true);   // Allow this replica to be eligible to become the primary table (for active-passive switchover).

    // Construct the request.
    UpdateGlobalTableRequest request = new UpdateGlobalTableRequest(
                // The ID of the global table.
                "gt-ee1b54db-f5d9-43f3-ad36-ec44********",
                // The name of the global table.
                "t-gt-test-1",  
                phyTable
    );
    // Send the request.
    UpdateGlobalTableResponse response = client.updateGlobalTable(request);
    System.out.println("Update succeeded. Request ID: " + response.getRequestId());
}