mysql6表清理跟回收空间
文章目录
- mysql6表清理跟回收空间
- 1.清理表
- 2.备份表或者备份库
- 3.回收表空间
- 4.查看
- 5.验证业务
1.清理表
## 登录
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.6.28-log MySQL Community Server (GPL)Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.## 清理表
delete from analogcg.cg_iea_t_info where CreateTime<='2025-06-15 00:00:00';
delete from analogcg.cg_log where CreateTime<='2025-06-15 00:00:00';
delete from analogcg.cg_sqip_t_info where CreateTime<='2025-06-15 00:00:00';
2.备份表或者备份库
## 因为这个表比较大,所以进行空间的回收,提高查询的性能create table cg_log0717 as select * from analogcg.cg_log ;
3.回收表空间
OPTIMIZE TABLE analogcg.cg_log ;
4.查看
到数据库所在的目录,可以看到cg_log.ibd 比之前小了很多
C:\ProgramData\MySQL\MySQL Server 5.6\data\analogcg