All Products
Search
Document Center

Tablestore:Delete a single row

Last Updated:Jun 22, 2026

Delete a single row from a Tablestore table by using the .NET SDK.

Prerequisites

Initialize Tablestore Client

Method

public DeleteRowResponse DeleteRow(DeleteRowRequest request)

Asynchronous method:

public Task<DeleteRowResponse> DeleteRowAsync(DeleteRowRequest request)

DeleteRowRequest parameters

Parameter

Type

Description

tableName (Required)

string

The name of the table.

primaryKey (Required)

PrimaryKey

The names and values of the primary key columns.

  • The data type of a primary key column must be STRING, INTEGER, or BINARY.

  • The number and data types of the primary key columns must match the table schema.

condition (Required)

Condition

The condition for the delete operation. For more information, see conditional update.

Sample code

The following example deletes the row whose primary key value is "row1" from the test_table table.

try
{
    // Construct the primary key.
    PrimaryKey primaryKey = new PrimaryKey
    {
        { "id", new ColumnValue("row1") }
    };
    // A condition is required to delete a row. RowExistenceExpectation.IGNORE indicates that the operation proceeds without checking if the row exists.
    Condition condition = new Condition(RowExistenceExpectation.IGNORE);

    // Send the request to delete the row.
    DeleteRowRequest deleteRowRequest = new DeleteRowRequest("test_table", condition, primaryKey);
    DeleteRowResponse deleteRowResponse = client.DeleteRow(deleteRowRequest);
    Console.WriteLine($"RequestId: {deleteRowResponse.RequestID}");
    Console.WriteLine($"Read CU Cost: {deleteRowResponse.ConsumedCapacityUnit.Read}");
    Console.WriteLine($"Write CU Cost: {deleteRowResponse.ConsumedCapacityUnit.Write}");
}
catch (Exception ex)
{
    Console.WriteLine($"Delete row failed, exception: {ex.Message}");
}

References

Batch write data