All Products
Search
Document Center

Tablestore:Delete a single row of data

Last Updated:Jun 22, 2026

Delete a single row from a Tablestore data table by specifying the table name and the primary key of the row.

Before you begin

Initialize the Tablestore client

Method

public function deleteRow(array $request)

$request parameters

Name

Type

Description

table_name (Required)

string

The name of the data table.

primary_key (Required)

array

The primary key of the row to delete, including column names and values.

  • The data types of primary key columns can be STRING, INTEGER, or BINARY.

  • The number and types of primary key columns must match those defined in the data table.

condition (Required)

array

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

transaction_id (Optional)

string

The ID that uniquely identifies a local transaction. For more information, see Local transactions.

Example

Delete the row whose primary key value is row1 from the test_table table:

try{
    $response = $client->deleteRow(array (
        'table_name' => 'test_table',
        'primary_key' => array (
            array ('id', 'row1')
        ),
        // A condition is required to delete a row. RowExistenceExpectationConst::CONST_IGNORE specifies that the existence of the row is not checked.
        'condition' => RowExistenceExpectationConst::CONST_IGNORE
    ));

    echo "Read CU Cost: " . $response['consumed']['capacity_unit']['read'] . "\n";
    echo "Write CU Cost: " . $response['consumed']['capacity_unit']['write'] . "\n";
} catch (Exception $e) {
    echo "Delete Row failed.";
}

References

Batch update data