所有数据库容量大小
select
table_schema as '数据库',
sum(table_rows) as '记录数',
sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',
sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
from information_schema.tables
group by table_schema
order by sum(data_length) desc, sum(index_length) desc;
所有数据库各表容量大小
select
table_schema as
table_name as
table_rows as
truncate(data_length/1024/1024, 2) as
truncate(index_length/1024/1024, 2) as
from information_schema.tables
order by data_length desc, index_length desc;
指定数据库容量大小
例:查看cake库容量大小
select
table_schema as '数据库',
sum(table_rows) as '记录数',
sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',
sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
from information_schema.tables
where table_schema='cake';
指定数据库各表容量大小
例:查看cake库各表容量大小
select
table_schema as
table_name as
table_rows as
truncate(data_length/1024/1024, 2) as
truncate(index_length/1024/1024, 2) as
from information_schema.tables
where table_schema=
order by data_length desc, index_length desc;
下面是执行案例
MySQL [cake]> select
-> table_schema as '数据库',
-> sum(table_rows) as '记录数',
-> sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',
-> sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
-> from information_schema.tables
-> where table_schema='cake';
+
| 数据库 | 记录数 | 数据容量(MB) | 索引容量(MB) |
+
| cake | 11288411 | 62084.71 | 493.86 |
+
1 row in set (0.44 sec)
MySQL [cake]> select
-> table_schema as '数据库',
-> table_name as '表名',
-> table_rows as '记录数',
-> truncate(data_length/1024/1024, 2) as '数据容量(MB)',
-> truncate(index_length/1024/1024, 2) as '索引容量(MB)'
-> from information_schema.tables
-> where table_schema='cake'
-> order by data_length desc, index_length desc;
+
| 数据库 | 表名 | 记录数 | 数据容量(MB) | 索引容量(MB) |
+
| cake | abc-aaaaa-aaaaaaa | 24485 | 18287.54 | 7.90 |
| cake | users_history | 143010 | 9232.84 | 0.00 |
| cake | shop_product | 124804 | 8975.21 | 48.29 |
| cake | abc_abcdefgd | 61376 | 6618.92 | 33.71 |
| cake | cakefo_shop_product | 82390 | 4331.40 | 0.00 |
| cake | information | 104199 | 3398.68 | 32.21 |
| cake | stock_history | 9559497 | 3385.87 | 0.00 |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
2021-08-17 在Typescript项目中,使用ESLint和Prettier,以及解决保存代码后ESLint配置冲突问题