All Products
Search
Document Center

Tablestore:DeleteRow

Last Updated:Aug 23, 2024

Deletes a row of data.

Request syntax

message DeleteRowRequest {
    required string table_name = 1;
    required bytes primary_key = 2; // The primary key is encoded as binary data in the PlainBuffer format. 
    required Condition condition = 3;
    optional ReturnContent return_content = 4;
    optional string transaction_id = 5;
}

Parameter

Type

Required

Description

table_name

string

Yes

The name of the data table.

primary_key

bytes

Yes

The primary key of the row that you want to delete.

The primary key is encoded in the PlainBuffer format. For more information about PlainBuffer, see PlainBuffer.

condition

Condition

Yes

Specifies whether to perform row existence check before a data operation. Default value: IGNORE. Valid values:

  • IGNORE: Row existence check is not performed.

    When you set the condition parameter to IGNORE, the operation is successful regardless of whether the row exists.

  • EXPECT_EXIST: The row is expected to exist.

    When you set the condition parameter to EXPECT_EXIST, the delete operation is successful if the row exists, and the delete operation fails and an error is reported if the row does not exist.

return_content

ReturnContent

No

The type of data to return after the row is successfully written. Only the primary key can be returned. In most cases, this parameter is used by the auto-increment primary key column feature.

transaction_id

string

No

The ID of the local transaction. This parameter is required if you want to use a local transaction to delete data.

Response syntax

message DeleteRowResponse {
    required ConsumedCapacity consumed = 1;
    optional bytes row = 2;
}

Parameter

Type

Description

consumed

ConsumedCapacity

The number of capacity units (CUs) that are consumed by the operation. For more information, see CU consumption.

row

bytes

The data that is returned if you specify a value for return_content. If you do not specify a value for return_content or no return value exists, NULL is returned.

The returned data is encoded in the PlainBuffer format. For more information about PlainBuffer, see PlainBuffer.

Use Tablestore SDKs

You can use the following Tablestore SDKs to delete a single row of data:

CU consumption

  • If the row that you want to delete does not exist, the number of consumed CUs varies based on the value that you specified for the condition parameter.

    • If the value of the condition parameter is IGNORE, the number of consumed write CUs is rounded up from the value that is calculated by using the following formula: Number of consumed write CUs = Size of data in all primary key columns of the row/4 KB.

    • If the value of the condition parameter is EXPECT_EXIST, the row fails to be deleted. One write CU and one read CU are consumed.

  • If the row that you want to delete exists, the number of consumed CUs varies based on the value that you specified for the condition parameter.

    • If the value of the condition parameter is IGNORE, the number of consumed write CUs is rounded up from the value that is calculated by using the following formula: Number of consumed write CUs = Size of data in all primary key columns of the row/4 KB.

    • If the value of the condition parameter is EXPECT_EXIST, both write and read CUs are consumed. The number of consumed write CUs is rounded up from the value that is calculated by using the following formula: Number of consumed write CUs = Size of data in all primary key columns of the row/4 KB. The number of consumed read CUs is rounded up from the value that is calculated by using the following formula: Number of consumed read CUs = Size of data in all primary key columns of the row/4 KB.

    For more information about how to calculate the data size, see Billing overview.

  • If the request times out and the results are undefined, CUs may or may not be consumed.

  • If an HTTP status code 5xx is returned, which indicates that an internal error occurred, the operation does not consume CUs. If other errors are returned, one write CU is consumed.