All Products
Search
Document Center

Tablestore:Delete a single row of data

更新时间:Mar 11, 2026

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

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 the primary key column names and values.

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

  • The number and types of primary keys must match those of the data table.

condition (Required)

array

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

transaction_id (Optional)

string

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

Example

Delete the row with primary key value row1 from test_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