Call the StartLocalTransaction operation to create a local transaction. When the local transaction feature is enabled for a data table, you can create transactions scoped to a single partition key value. This lets you perform atomic read and write operations on one or more rows.
Precautions
-
You must enable local transactions when you create a data table. Use the Tablestore console, Tablestore SDK for Java V5.11.0 or later, or the latest version of Tablestore SDK for Go. For more information, see Create a data table.
ImportantIf you need local transactions for an existing data table but did not enable the feature when the table was created, submit a ticket. You may also join DingTalk group 36165029092 (Tablestore Technical Discussion Group-3) for assistance
-
The auto-increment primary key feature and the local transaction feature cannot be used together.
Request message structure
message StartLocalTransactionRequest {
required string table_name = 1;
required bytes key = 2;
}
|
Name |
Type |
Required |
Description |
|
table_name |
string |
Yes |
The name of the data table. |
|
key |
bytes |
Yes |
The partition key value of the data table. The value is encoded in Plainbuffer format. For more information, see Plainbuffer encoding. |
Response message structure
message StartLocalTransactionResponse {
required string transaction_id = 1;
}
|
Name |
Type |
Required |
Description |
|
transaction_id |
string |
Yes |
The ID of the local transaction. |
Using the SDK
You can use local transactions with the following SDKs.