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 查看数据库索引大小,数据库表大小