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 | Yes | Specifies whether to perform row existence check before a data operation. Default value: IGNORE. Valid values:
| |
return_content | 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 | 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:
Tablestore SDK for Java: Delete a single row of data
Tablestore SDK for Go: Delete a single row of data
Tablestore SDK for Python: Delete a single row of data
Tablestore SDK for Node.js: Delete a single row of data
Tablestore SDK for .NET: Delete a single row of data
Tablestore SDK for PHP: 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.