查看mysql数据库指定库或指定表的容量大小

一、查询某实例下所有数据库的容量大小(单位:G)

sql语句:

use information_schema;查看mysql数据库指定库或指定表的容量大小
        select concat(round(sum(data_length/1024/1024/1024),2),'G')  from tables;  #查询所有库的容量大小查看mysql数据库指定库或指定表的容量大小

二、查询指定数据库、指定表的容量大小(单位:MB)

use information_schema;

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from information_schema.tables where table_schema={库名};use information_schema;
查看mysql数据库指定库或指定表的容量大小查看mysql数据库指定库或指定表的容量大小

三、查询指定数据库、指定表的行数

use information_schema;

SELECT sum(TABLE_ROWS) FROM information_schema.tables where table_schema={库名} and TABLE_NAME ={表名};查看mysql数据库指定库或指定表的容量大小