• DELETE
    • 语法图
    • 示例
    • MySQL 兼容性
    • 另请参阅

    DELETE

    DELETE 语句用于从指定的表中删除行。

    语法图

    DeleteFromStmt:

    DeleteFromStmt

    示例

    1. mysql> CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY auto_increment, c1 INT NOT NULL);
    2. Query OK, 0 rows affected (0.11 sec)
    3. mysql> INSERT INTO t1 (c1) VALUES (1),(2),(3),(4),(5);
    4. Query OK, 5 rows affected (0.03 sec)
    5. Records: 5 Duplicates: 0 Warnings: 0
    6. mysql> SELECT * FROM t1;
    7. +----+----+
    8. | id | c1 |
    9. +----+----+
    10. | 1 | 1 |
    11. | 2 | 2 |
    12. | 3 | 3 |
    13. | 4 | 4 |
    14. | 5 | 5 |
    15. +----+----+
    16. 5 rows in set (0.00 sec)
    17. mysql> DELETE FROM t1 WHERE id = 4;
    18. Query OK, 1 row affected (0.02 sec)
    19. mysql> SELECT * FROM t1;
    20. +----+----+
    21. | id | c1 |
    22. +----+----+
    23. | 1 | 1 |
    24. | 2 | 2 |
    25. | 3 | 3 |
    26. | 5 | 5 |
    27. +----+----+
    28. 4 rows in set (0.00 sec)

    MySQL 兼容性

    DELETE 语句与 MySQL 完全兼容。如有任何兼容性差异,请在 GitHub 上提交 issue。

    另请参阅

    • INSERT
    • SELECT
    • UPDATE
    • REPLACE