All Products
Search
Document Center

Tablestore:Bind a global table

Last Updated:Jan 09, 2026

This topic describes how to use the Java software development kit (SDK) to add one or more replicas to a global table.

Notes

After the bind operation is successful, the system asynchronously binds the new replica and synchronizes data. Call the DescribeGlobalTable operation to view the current status of the global table. If the returned status is Active, the new replica is successfully bound.

Prerequisites

Initialize a client.

Method description

public BindGlobalTableResponse bindGlobalTable(BindGlobalTableRequest request) throws TableStoreException, ClientException

BindGlobalTableRequest parameters

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

    Note

    If you do not know the global table ID, you can call the DescribeTable operation to query the details of a table replica. If the table is a replica in a global table, the response from the DescribeTable operation contains the global table ID.

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

  • placements (Required) List<Placement>: The list of configurations for the new placement locations. This list includes the following parameters:

    Name

    Type

    Description

    regionId (Required)

    String

    The region ID.

    instanceName (Required)

    String

    The instance name.

    writable (Required)

    boolean

    Specifies whether the replica is writable. The default value is false. In active-passive mode, keep the default configuration.

Example

private static void bindGlobalTableExample(SyncClient client) {
    // Create a request.
    BindGlobalTableRequest request = new BindGlobalTableRequest(
                // The global table ID.
                "gt-ee1b54db-f5d9-43f3-ad36-ec44********",
                // The name of the global table.
                "my-global-table"
    ); 

    // Create a list of placements. The list must contain at least one replica configuration.
    List<GlobalTableTypes.Placement> placements = new ArrayList<>();

    // Example: Add a replica in the China (Hangzhou) region.
    GlobalTableTypes.Placement hangzhouReplica = new GlobalTableTypes.Placement(
                // The ID of the region where the replica is located.
                "cn-hangzhou", 
                // The name of the instance to which the replica belongs.
                "instance-replica-hz",
                // In active-passive mode, the replica table is not writable. The default value is false.
                false
    );

    // Example: Add a replica in the China (Shanghai) region.
    GlobalTableTypes.Placement shanghaiReplica = new GlobalTableTypes.Placement(
                // 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", 
                // In active-passive mode, the replica table is not writable. The default value is false.
                false
    );

    placements.add(hangzhouReplica);
    placements.add(shanghaiReplica);
    request.setPlacements(placements);

    // Send the request.
    BindGlobalTableResponse response = client.bindGlobalTable(request);
    System.out.println("Bind succeeded. Request ID: " + response.getRequestId());
}