[TDR Generic Table] [MySQL Protocol Compatibility Interface] Delete Records
1. Interface Description
Delete existing records from 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 Delete Statement
The WHERE clause of delete 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 delete data frommysql_table, theWHEREclause form is as follows:
WHERE k1=1 AND k2=2 AND k3='one';
- When using
primarykey+ filter condition to delete data frommysql_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 delete data frommysql_table, theWHEREclause form is as follows:
WHERE k1=1 AND k2=2;
Note: When using index to delete data, multiple records may be deleted at one time.
4. SQL Examples
- When using
primarykeyto delete a record frommysql_table, the SQL statement has the following two forms:
DELETE FROM mysql_table WHERE k1=1 AND k2=2 AND k3='one';
DELETE FROM mysql_table 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 delete multiple records frommysql_tablein batches, the SQL statement is as follows:
DELETE FROM mysql_table 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 delete multiple records frommysql_tablein batches, the SQL statement is as follows:
DELETE FROM mysql_table WHERE k1=1 AND k2=2;
Filter conditions are not supported when using index to delete records.
5. FAQ
For details, see Meaning and Handling of Error Codes.
6. Other Reference Documents
[TDR Generic Table][C++ SDK] Interface Description for Deleting a Record
[TDR Generic Table] [Java SDK] Interface Description for Deleting a Record.
[TDR Generic Table] [Go SDK] Interface Description for Deleting a Record.