All Products
Search
Document Center

Tablestore:Delete a row

Last Updated:Aug 12, 2026

Use the Tablestore SDK for Go to delete a row identified by its primary key from a Wide Column model table.

Prerequisites

Install the Tablestore SDK for Go and initialize the client.

Description

Call DeleteRow to delete a row identified by its primary key. You can use Condition to control whether the deletion is performed.

func (tableStoreClient *TableStoreClient) DeleteRow(request *DeleteRowRequest) (*DeleteRowResponse, error)

The following sample deletes the row whose primary key value is row1 from the example_table table.

primaryKey := &tablestore.PrimaryKey{}
primaryKey.AddPrimaryKeyColumn("id", "row1")

change := &tablestore.DeleteRowChange{
    TableName:  "example_table",
    PrimaryKey: primaryKey,
}
change.SetCondition(tablestore.RowExistenceExpectation_EXPECT_EXIST)

_, err := client.DeleteRow(&tablestore.DeleteRowRequest{DeleteRowChange: change})
if err != nil {
    log.Fatal(err)
}

Parameters

DeleteRowRequest contains the following parameter.

Name

Type

Description

DeleteRowChange (required)

*DeleteRowChange

The row deletion configuration.

Row change

DeleteRowChange contains the following parameters.

Name

Type

Description

TableName (required)

string

The table name.

PrimaryKey (required)

*PrimaryKey

The primary key of the row. The names, order, and types of the primary key columns must match the table schema.

Condition (required)

*RowCondition

The deletion condition, which can include a row existence condition and a column condition. For more information, see Use conditional updates.

TransactionId (optional)

*string

The local transaction ID. Specify this parameter only for a deletion in a local transaction. For more information, see Use local transactions.