Mysql DBA 高级运维学习笔记-删除表中数据
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Mysql DBA 高级运维学习笔记-删除表中数据,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2650字,纯文字阅读大概需要4分钟。
内容图文
![Mysql DBA 高级运维学习笔记-删除表中数据](/upload/InfoBanner/zyjiaocheng/499/f361719bdab14427ba4627de8e51d172.jpg)
- 命令语法:delete from 表名 where 表达式
实践:
(1)删除表student中编号为3的记录
mysql> use zbf
Database changed
mysql> select * from student;
+----+-----------+-----+--------+
| id | name | age | dept |
+----+-----------+-----+--------+
| 1 | zbf666| 29 | linux |
| 2 | lisi | 28 | mysql |
| 3 | zhangsan | 21 | python |
| 4 | woshishei | 24 | java |
+----+-----------+-----+--------+
4 rows in set (0.06 sec)
mysql> delete from student where id=3;
Query OK, 1 row affected (0.01 sec)
mysql> select * from student;
+----+-----------+-----+-------+
| id | name | age | dept |
+----+-----------+-----+-------+
| 1 | zbf666| 29 | linux |
| 2 | lisi | 28 | mysql |
| 4 | woshishei | 24 | java |
+----+-----------+-----+-------+
3 rows in set (0.02 sec)
(2)也可以删除name等于lisi的行
mysql> select * from student;
+----+-----------+-----+-------+
| id | name | age | dept |
+----+-----------+-----+-------+
| 1 | zbf666| 29 | linux |
| 2 | lisi | 28 | mysql |
| 4 | woshishei | 24 | java |
+----+-----------+-----+-------+
3 rows in set (0.02 sec)
mysql> delete from student where name=‘lisi‘;
Query OK, 1 row affected (0.01 sec)
mysql> select * from student;
+----+-----------+-----+-------+
| id | name | age | dept |
+----+-----------+-----+-------+
| 1 | zbf666| 29 | linux |
| 4 | woshishei | 24 | java |
+----+-----------+-----+-------+
2 rows in set (0.00 sec)
(3)也可以删除id大于3的行
mysql> select * from student;
+----+-----------+-----+-------+
| id | name | age | dept |
+----+-----------+-----+-------+
| 1 | zbf666| 29 | linux |
| 4 | woshishei | 24 | java |
+----+-----------+-----+-------+
2 rows in set (0.00 sec)
mysql> delete from student where id>3;
Query OK, 1 row affected (0.01 sec)
mysql> select * from student;
+----+--------+-----+-------+
| id | name | age | dept |
+----+--------+-----+-------+
| 1 | zbf666 | 29 | linux |
+----+--------+-----+-------+
1 row in set (0.00 sec)
提示:不加条件就是全部删除,也是非常危险的操作,这里接不演示了。delete from student 。
2.命令语法Truncate table 表名
Truncate table student; 清空表中所欲内容
mysql> truncate table student;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from student;
Empty set (0.00 sec)
Truncate from srudent和delete from student区别
a.Truncate table student;更快,清空物理文件。
b.delete from student;逻辑清除,按行删。
Mysql DBA 高级运维学习笔记-删除表中数据
标签:truncate 9.1 内容 dba 实践 delete -- 演示 区别
本文系统来源:http://blog.51cto.com/10642812/2065957
内容总结
以上是互联网集市为您收集整理的Mysql DBA 高级运维学习笔记-删除表中数据全部内容,希望文章能够帮你解决Mysql DBA 高级运维学习笔记-删除表中数据所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。