SQL DELETE 语句 |
您所在的位置:网站首页 › sql删除数据 › SQL DELETE 语句 |
❮ 上一节
下一节 ❯
SQL DELETE 语句
DELETE 语句
DELETE 语句用于删除表中的记录。 DELETE 语法 DELETE FROM table_name WHERE condition;注释: 请注意 SQL DELETE 语句中的 WHERE 子句! WHERE 子句规定哪条记录或者哪些记录需要删除。如果您省略了 WHERE 子句,所有的记录都将被删除! 演示数据库以下是从 Northwind 示例数据库的 "客户(Customers)" 表中查询的内容: CustomerID CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico 3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico 4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK 5 Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå S-958 22 Sweden DELETE 实例以下 SQL 语句从 客户(customer) 表中删除客户 "Alfreds Futterkiste": 实例 DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste'; 亲自试一试 »客户(Customers) 表现在如下所示: CustomerID CustomerName ContactName Address City PostalCode Country 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico 3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico 4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK 5 Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå S-958 22 Sweden 删除所有行可以在不删除表的情况下删除所有的行。这意味着表的结构、属性和索引都是完整的: DELETE FROM table_name;以下 SQL 语句删除 "Customers" 表中的所有行,而不删除该表: 实例 DELETE FROM Customers; 亲自试一试 » ❮ 上一节 下一节 ❯ |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |