1555426124751.png

    • 使用 DELETE 语句从表中删除数据1555426162264.png
      1. DELETE FROM table_name [WHERE <condition>];

    table_name指定要执行删除操作的表;“[WHERE ]”为可选参数,指定删除条件,如果没有WHERE子句,DELETE语句将删除表中的所有记录。

    • 使用 WHERE 子句删除指定的记录。
    1. DELETE FROM departments
    2. WHERE department_name = 'Finance';
    • 如果省略 WHERE 子句,则表中的全部数据将被删除
    1. DELETE FROM copy_emp;
    • 删除中的数据完整性错误
    1. DELETE FROM departments
    2. WHERE department_id = 60;

    1555426258516.png

    说明:You cannot delete a row that contains a primary key that is used as a foreign key in another table.