[TDR Generic Table] [MySQL Protocol Compatibility Interface] Update Records
1. Interface Description
Update existing records to a specified table.
2. Preparations
Refer to Preparation document, create mysql_table table, and use MySQL Client to connect to TcaplusDB successfully.
3. Syntax Rules of WHERE Clause of Update Statement
The WHERE clause of update statement consists of two parts: (1) required part: index or primarykey; (2) optional part: filter conditions.
The fields in indexor primarykey can only be queried equivalently, and the fields that make up index or primarykey can only be connected by the operator AND;
Filter conditions support NOT, =, >, <, !=, >= and <=. Multiple filter conditions can be connected with AND or OR, and support to filter key fields, value fields, version fields, and TTL fields.
- When using
primarykeyto update data tomysql_table, theWHEREclause form is as follows:
WHERE k1=1 AND k2=2 AND k3='one';
- When using
primarykey+ filter condition to update data tomysql_table, theWHEREclause form is as follows: (if the filter condition containsORoperator, the filter condition must be bracketed):
WHERE k1=1 AND k2=2 AND k3='one' AND (Filter condition);
- When using
indexto update data tomysql_table, theWHEREclause form is as follows:
WHERE k1=1 AND k2=2;
Note: When using index to update data, multiple records may be updated at one time.
4. SQL Examples
- When using
primarykeyto update a record tomysql_table, the SQL statement has the following two forms:
UPDATE mysql_table SET v1=v1+1, v2=2 WHERE k1=1 AND k2=2 AND k3='one';
UPDATE mysql_table SET v1=v1-1, v2=2 WHERE k1=1 AND k2=2 AND k3='one' AND (v1>=4 OR v2<=4);
The content in the brackets of the 2nd SQL statement above is the filter condition.
- When using
primarykeyto update multiple records tomysql_tablein batches, the SQL statement is as follows:
UPDATE mysql_table SET v1=v1-1, v2=v2+2 WHERE k1=1 AND k2=2 AND k3='one' OR k1=1 AND k2=2 AND k3='two' AND (v1>=4 OR v2<=4);
The content in the brackets of the SQL statement above is the filter condition.
- When using
indexto update multiple records tomysql_tablein batches, the SQL statement is as follows:
UPDATE mysql_table SET v1=v1+1, v2=2 WHERE k1=1 AND k2=2;
Filter conditions are not supported when using index to update records.
5. FAQ
For details, see Meaning and Handling of Error Codes.
6. Other Reference Documents
[TDR Generic Table] [C++ SDK] Interface Description for Updating a Record
[TDR Generic Table] [Java SDK] Interface Description for Updating a Record
[TDR Generic Table][Go SDK] Interface Description for Updating a Record
[TDR Generic Table][C++ SDK] Interface Description for Auto-increment of Fields.
[TDR Generic Table] [Java SDK] Interface Description for Auto-increment of Part Fields in a Record.
[TDR Generic Table] [Java SDK] Interface Description for Auto-increment of Part Fields.