MySQL查看数据库表容量大小的方法示例

作者:傲雪星枫 时间:2024-01-14 23:19:47 

本文介绍MySQL查看数据库表容量大小的命令语句,提供完整查询语句及实例,方便大家学习使用。

1.查看所有数据库容量大小


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;

2.查看所有数据库各表容量大小


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
order by data_length desc, index_length desc;

3.查看指定数据库容量大小

例:查看mysql库容量大小


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='mysql';

MySQL查看数据库表容量大小的方法示例 

4.查看指定数据库各表容量大小

例:查看mysql库各表容量大小


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='mysql'
order by data_length desc, index_length desc;

MySQL查看数据库表容量大小的方法示例

来源:https://blog.csdn.net/fdipzone/article/details/80144166

标签:MySQL,数据库,容量大小
0
投稿

猜你喜欢

  • 使用FORFILES命令来删除SQLServer备份的批处理

    2012-05-08 06:47:06
  • Oracle 数据表分区的策略

    2023-07-08 12:19:18
  • python数据分析之DataFrame内存优化

    2021-09-03 23:08:29
  • SQL Server和Oracle并行处理方法对比

    2009-01-20 15:48:00
  • Win2003服务器安装及设置教程 MySQL安全设置图文教程

    2024-01-28 17:55:46
  • TensorFlow卷积神经网络之使用训练好的模型识别猫狗图片

    2023-09-07 03:34:41
  • 微信小程序 ES6Promise.all批量上传文件实现代码

    2024-02-26 15:32:10
  • 在python中获取div的文本内容并和想定结果进行对比详解

    2021-09-05 07:29:37
  • javascript框架设计之框架分类及主要功能

    2024-04-18 09:33:40
  • python异常处理和日志处理方式

    2023-04-25 09:36:54
  • pycharm安装深度学习pytorch的d2l包失败问题解决

    2022-11-26 03:36:56
  • 详解在Python程序中自定义异常的方法

    2021-05-17 00:34:28
  • 在Ubuntu 20.04中安装Pycharm 2020.1的图文教程

    2022-05-28 23:03:48
  • mysql 8.0.15 winx64解压版图文安装教程

    2024-01-16 08:22:32
  • Linux环境下安装mysql5.7.36数据库教程

    2024-01-19 15:42:02
  • PHP微信支付实例解析

    2024-05-02 17:15:56
  • js修改原型的属性使用介绍

    2024-04-10 10:51:03
  • python rolling regression. 使用 Python 实现滚动回归操作

    2021-01-11 09:38:07
  • MSSQL安全设置的具体步骤和方法小结

    2012-07-11 15:54:11
  • python sys模块sys.path使用方法示例

    2023-01-12 22:52:15
  • asp之家 网络编程 m.aspxhome.com