首页 > 数据库 >MySQL查看数据库表容量大小

MySQL查看数据库表容量大小

时间:2022-09-21 13:45:30浏览次数:60  
标签:1024 truncate 容量 数据库 length MySQL table schema

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

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;

标签:1024,truncate,容量,数据库,length,MySQL,table,schema
From: https://www.cnblogs.com/kevinlucky/p/16715313.html

相关文章

  • 您在 Elasticsearch 中的数据库数据
    您在Elasticsearch中的数据库数据如果您像我一样喜欢Elasticsearch的灵活性和可扩展性。与Kibana搭配使用,它成为利用数据的完美工具,即使对于非技术人员也是如此。......
  • 美团数据库运维自动化系统构建之路
    文章链接 美团数据库运维自动化系统构建之路-美团技术团队(meituan.com)本文整理自美团点评技术沙龙第10期:数据库技术架构与实践。美团点评技术沙龙由美团点评技术团......
  • MySQL主从同步详解与配置
    MySQL主从同步详解与配置走鹿带凨爱生活,有理想,善思考,能沟通 21人赞同了该文章 https://zhuanlan.zhihu.com/p/335142300MySQL主从同......
  • MySQL指令
    目录SQL语言的分类DQL(数据查询语言)select关键字组合顺序select简单查询用法select条件查询select函数使用select多表连接查询select子查询Union结果集合并Limit分页显示DDL......
  • Mysql SQL查询今天、昨天、n天内、第n天的数据
    查询5分钟前的数据select*fromtablewhereend_datebetweendate_add(now(),interval-300SECOND)andNOW()  查询当天的所有数据SELECT*FROM表名WHEREDAT......
  • mysql8.0绿色版安装
    下载软件直达官网下载Community版:https://dev.mysql.com/downloads/mysql/然后拉倒下方点击对应版本位数下载2.安装下载完压缩包之后就解压,2.1在程序安装目录创建my.......
  • mysql实现oracle序列_mysql实现oracle序列
    mysql实现oracle序列的方案1.建表,表结构为:droptableifexistssequence;createtablesequence(seq_nameVARCHAR(50)NOTNULL,--序列名称current_valINTNO......
  • mysql安装和连接Navicat
    mysql安装可参考下面博客,按照步骤可以走通,实测有效,网上其他的乱七八糟的,诶https://www.cnblogs.com/itcui/p/15511683.html安装结束后,由于我安装的是8.0版本,在连接Navica......
  • MySQL维护之存储引擎(表类型)
    MySQL中的数据用各种不同的技术存储在文件(或内存)中。在MySQL架构原理之体系架构-池塘里洗澡的鸭子-博客园(cnblogs.com)中可以看到其在MySQL中的第3层。官......
  • webForm 远程连接 MSSQL 数据库
    在配置文件当中,使用密码登录服务器. stringconnStr2="server=101.66.2.210\\WIN-ORJPABRM5O5,1433;uid=sa;pwd=as2020;database=Test(DEV);";//创建SqlConnec......