All Products
Search
Document Center

Tablestore:UpdateRow

Last Updated:Apr 29, 2026

The UpdateRow operation updates data in a specified row.

Note

If the specified row does not exist, a new row is inserted. If the row exists, UpdateRow adds, modifies, or deletes the values of specified attribute columns based on the request.

Request message structure

message UpdateRowRequest {
    required string table_name = 1;
    required bytes row_change = 2;
    required Condition condition = 3;
    optional ReturnContent return_content = 4;
    optional string transaction_id = 5;
}

Name

Type

Required

Description

table_name

string

Yes

The name of the table to update.

row_change

bytes

Yes

The update data, including the primary key and attribute columns, encoded in PlainBuffer format. For more information, see PlainBuffer.

Tablestore adds, modifies, or deletes the values of specified attribute columns based on the UpdateType in row_change. Attribute columns not included in row_change are not affected.

Valid values for UpdateType:

  • PUT: The value must be a valid attribute column value. If the column does not exist, a new column is created. If the column exists, the value is overwritten.

  • DELETE: The value must be empty. Specify a timestamp to delete that specific version of the column.

  • DELETE_ALL: The value and timestamp must both be empty. This deletes all versions of the column.

    Note

    Deleting all attribute columns in a row is not the same as deleting the row. To delete the row, use the DeleteRow operation.

condition

Condition

Yes

Whether to check for row existence before updating. Valid values:

  • IGNORE (default): Skips the existence check. The operation succeeds regardless of whether the row exists.

  • EXPECT_EXIST: Requires the row to exist. If the row does not exist, the operation fails and returns an error.

return_content

ReturnContent

No

The type of data to return after a successful write. Only returning the primary key is supported, primarily for the auto-increment primary key column feature.

transaction_id

string

No

The local transaction ID. Set this parameter when using the local transaction feature.

Response message structure

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

Name

Type

Description

consumed

ConsumedCapacity

The capacity units consumed by the operation. For more information, see Capacity unit consumption.

row

bytes

The data returned when return_content is set. If return_content is not set or no value is returned, this parameter is NULL.

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

Use an SDK

Use an SDK for one of the following languages to update a single row.

Capacity unit consumption

  • If the row does not exist, the capacity units consumed depend on the condition check setting.

    • IGNORE: The write CUs consumed equal the sum of the primary key data size and the attribute column data size, divided by 4 KB and rounded up. For attribute columns being deleted, only the column name length is counted toward the data size.

    • EXPECT_EXIST: The operation fails and consumes 1 write CU and 1 read CU.

  • If the row exists, the capacity units consumed depend on the condition check setting.

    • IGNORE: The write CUs consumed equal the sum of the primary key data size and the attribute column data size, divided by 4 KB and rounded up. For attribute columns being deleted, only the column name length is counted toward the data size.

    • EXPECT_EXIST: Consumes the same write CUs as IGNORE, plus additional read CUs. The read CUs consumed equal the primary key data size divided by 4 KB and rounded up.

    For more information about how data size is calculated, see Pricing.

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

  • If an internal error occurs (HTTP status code: 5xx), no capacity units are consumed. For other errors, 1 write CU and 1 read CU are consumed.