当前位置: 移动技术网 > IT编程>数据库>MSSQL > SQLite Delete详解及实例代码

SQLite Delete详解及实例代码

2017年12月08日  | 移动技术网IT编程  | 我要评论

宜兴世纪大桥,丽图100,北京陪床保姆

sqlite delete详解

sqlite 的 delete 查询用于删除表中已有的记录。可以使用带有 where 子句的 delete 查询来删除选定行,否则所有的记录都会被删除。

语法

带有 where 子句的 delete 查询的基本语法如下:

delete from table_name
where [condition];

您可以使用 and 或 or 运算符来结合 n 个数量的条件。

实例

假设 company 表有以下记录:

id     name    age     address   salary
---------- ---------- ---------- ---------- ----------
1      paul    32     california 20000.0
2      allen    25     texas    15000.0
3      teddy    23     norway   20000.0
4      mark    25     rich-mond  65000.0
5      david    27     texas    85000.0
6      kim     22     south-hall 45000.0
7      james    24     houston   10000.0

下面是一个实例,它会删除 id 为 7 的客户:

sqlite> delete from company where id = 7;

现在,company 表有以下记录:

id     name    age     address   salary
---------- ---------- ---------- ---------- ----------
1      paul    32     california 20000.0
2      allen    25     texas    15000.0
3      teddy    23     norway   20000.0
4      mark    25     rich-mond  65000.0
5      david    27     texas    85000.0
6      kim     22     south-hall 45000.0

如果您想要从 company 表中删除所有记录,则不需要使用 where 子句,delete 查询如下:

sqlite> delete from company;

现在,company 表中没有任何的记录,因为所有的记录已经通过 delete 语句删除。

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网