2023-05-12 开启多语言插件支持……

mysql 查看数据库索引大小,数据库表大小

mysql 苏 demo 2686℃ 0评论

1. 查看数据库的索引空间大小

-- 以GB为单位
SELECT
CONCAT(ROUND(SUM(index_length)/(1024*1024*1024), 6), ' GB') AS 'Total Index Size'
FROM
information_schema.TABLES
WHERE
table_schema LIKE 'database';
-- 以MB为单位
SELECT
CONCAT(ROUND(SUM(index_length)/(1024*1024), 6), ' MB') AS 'Total Index Size'
FROM
information_schema.TABLES
WHERE
table_schema LIKE 'database';

2. 查看数据库的数据空间大小

-- 以GB为单位
SELECT
CONCAT(ROUND(SUM(data_length)/(1024*1024*1024), 6), ' GB') AS 'Total Data Size'
FROM
information_schema.TABLES
WHERE
table_schema LIKE 'database';
-- 以MB为单位
SELECT
CONCAT(ROUND(SUM(data_length)/(1024*1024), 6), ' MB') AS 'Total Data Size'
FROM
information_schema.TABLES
WHERE
table_schema LIKE 'database';

3. 查看数据库中所有表的信息

SELECT
CONCAT(table_schema,'.',table_name) AS 'Table Name',
table_rows AS 'Number of Rows',
CONCAT(ROUND(data_length/(1024*1024),6),' MB') AS 'Data Size',
CONCAT(ROUND(index_length/(1024*1024),6),' MB') AS 'Index Size',
CONCAT(ROUND((data_length+index_length)/(1024*1024),6),' MB') AS'Total Size'
FROM
information_schema.TABLES
WHERE
table_schema LIKE 'database';

打赏

转载请注明:苏demo的别样人生 » mysql 查看数据库索引大小,数据库表大小

   如果本篇文章对您有帮助,欢迎向博主进行赞助,赞助时请写上您的用户名。
支付宝直接捐助帐号oracle_lee@qq.com 感谢支持!
喜欢 (0)or分享 (0)