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