由于MySql表的相关信息都存放在information_schema
表空间下面的tables
里面,所以查询表空间大小的时候也是查这个表里面的数据.
查询整个库里面所有表的信息
select * from information_schema.tables
where table_schema='你要查询的库';
查询整个库里面所有表的大小
select table_name,table_rows,data_length+index_length,
concat(round((data_length+index_length)/1024/1024,2),'MB')
data from information_schema.tables where table_schema='你要查询的库'
查询该库某个表的大小
select table_name,table_rows,data_length+index_length,
concat(round((data_length+index_length)/1024/1024,2),'MB')
data from information_schema.tables where table_schema='你要查询的库'
and table_name='你要查询的表';