80人参与 • 2026-05-10 • Mysql
select sum(t1.data_size ) as data_sum_size, sum(t1.index_size) as index_sum_size from( select table_name, table_schema, truncate(data_length/1024/1024,2) as data_size, -- 查看数据占用大小单位为mb truncate(index_length/1024/1024,2) as index_size -- 查看索引占用大小 单位为mb from information_schema.tables where table_schema = '数据库名' order by data_length desc) t1;
如果想查看该数据库中每个表占用大小的话
select table_name, table_schema, truncate(data_length/1024/1024,2) as data_size, -- 查看数据占用大小单位为mb truncate(index_length/1024/1024,2) as index_size -- 查看索引占用大小 单位为mb from information_schema.tables where table_schema = '数据库名' order by data_length desc
select sum(t1.table_rows) as table_sum from ( select table_name,table_rows from information_schema.tables where table_schema = '数据库名' order by table_rows desc) t1;
如果要查看数据库中每个表的行数的话
select table_name,table_rows from information_schema.tables where table_schema = '数据库名' order by table_rows des
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
您想发表意见!!点此发布评论
版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。
发表评论