Skip to content

Latest commit

 

History

History
64 lines (50 loc) · 1.68 KB

sql-statement-delete.md

File metadata and controls

64 lines (50 loc) · 1.68 KB
title summary aliases
DELETE | TiDB SQL Statement Reference
An overview of the usage of DELETE for the TiDB database.
/docs/dev/sql-statements/sql-statement-delete/
/docs/dev/reference/sql/statements/delete/

DELETE

The DELETE statement removes rows from a specified table.

Synopsis

DeleteFromStmt ::=
    'DELETE' TableOptimizerHints PriorityOpt QuickOptional IgnoreOptional ( 'FROM' ( TableName TableAsNameOpt IndexHintListOpt WhereClauseOptional OrderByOptional LimitClause | TableAliasRefList 'USING' TableRefs WhereClauseOptional ) | TableAliasRefList 'FROM' TableRefs WhereClauseOptional )

Examples

mysql> CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, c1 INT NOT NULL);
Query OK, 0 rows affected (0.11 sec)

mysql> INSERT INTO t1 (c1) VALUES (1),(2),(3),(4),(5);
Query OK, 5 rows affected (0.03 sec)
Records: 5  Duplicates: 0  Warnings: 0

mysql> SELECT * FROM t1;
+----+----+
| id | c1 |
+----+----+
|  1 |  1 |
|  2 |  2 |
|  3 |  3 |
|  4 |  4 |
|  5 |  5 |
+----+----+
5 rows in set (0.00 sec)

mysql> DELETE FROM t1 WHERE id = 4;
Query OK, 1 row affected (0.02 sec)

mysql> SELECT * FROM t1;
+----+----+
| id | c1 |
+----+----+
|  1 |  1 |
|  2 |  2 |
|  3 |  3 |
|  5 |  5 |
+----+----+
4 rows in set (0.00 sec)

MySQL compatibility

The DELETE statement in TiDB is fully compatible with MySQL. If you find any compatibility differences, report a bug.

See also