All Products
Search
Document Center

Tablestore:Delete a row

Last Updated:Aug 05, 2026

Use Tablestore SDK for Java to delete a row from a Wide Column model table by its complete primary key.

Prerequisites

Install Tablestore SDK for Java and initialize the client.

Description

Call deleteRow to delete a row and all of its attribute column data by its complete primary key. You can use condition to control whether the deletion is performed.

public DeleteRowResponse deleteRow(DeleteRowRequest deleteRowRequest) throws TableStoreException, ClientException

The following example deletes the row whose primary key is row1 from the data table delete_row_demo.

String tableName = "delete_row_demo";

PrimaryKeyBuilder primaryKeyBuilder = PrimaryKeyBuilder.createPrimaryKeyBuilder();
primaryKeyBuilder.addPrimaryKeyColumn("id", PrimaryKeyValue.fromString("row1"));
PrimaryKey primaryKey = primaryKeyBuilder.build();

RowDeleteChange rowDeleteChange = new RowDeleteChange(tableName, primaryKey);

client.deleteRow(new DeleteRowRequest(rowDeleteChange));

Parameters

DeleteRowRequest contains the following parameters.

Name

Type

Description

rowChange (required)

RowDeleteChange

The configurations for deleting a row.

transactionId (optional)

String

The local transaction ID. Set this parameter only when you delete data in a local transaction.

For information about how to obtain and use the ID, see Use local transactions.

Row change

rowChange is of the RowDeleteChange type and contains the following parameters.

Name

Type

Description

tableName (required)

String

The name of the table.

primaryKey (required)

PrimaryKey

The primary key of the row. Specify all primary key columns in the same order and with the same types as the table schema. Primary key columns support the STRING, INTEGER, and BINARY types.

condition (optional)

Condition

The delete condition. By default, Tablestore does not check whether the row exists.

For information about how to configure the condition, see Use conditional updates.