当前位置:数据库 > MySQL >>

SQL DELETE 语句

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

语法
DELETE FROM 表名称 WHERE 列名称 = 值Person:
LastName FirstName Address City
Gates Bill Xuanwumen 10 Beijing
Wilson Fred Zhongshan 23 Nanjing
删除某行
"Fred Wilson" 会被删除:

DELETE FROM Person WHERE LastName = 'Wilson' 结果:
LastName FirstName Address City
Gates Bill Xuanwumen 10 Beijing
删除所有行
可以在不删除表的情况下删除所有的行。这意味着表的结构、属性和索引都是完整的:

DELETE FROM table_name或者:

DELETE * FROM table_name

教程二

语法
DELETE FROM table_name
WHERE column_name = some_value
Person:
LastName FirstName Address City
Nilsen    Fred    Kirkegt 56    Stavanger
Rasmussen  Nina    Stien 12     Stavanger

删除某行
"Nina Rasmussen"会被删除:

DELETE FROM Person WHERE LastName = 'Rasmussen'
结果:
LastName FirstName Address City
Nilsen    Fred    Kirkegt 56    Stavanger

删除所有行
可以在不删除表的情况下删除所有的行。这意味着表的结构、属性和索引都是完整的:

补充:数据库,mysql教程
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,