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

在MySQL Workbench中运行以下SQL语句,查看数据库中所有表的表名、表行数、数据空间大小、索引空间大小和总大小:
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';
其中,database是待查看数据库的名称,例如:lsqdb%。运行结果如下图所示: