select TABLE_NAME, concat(truncate(data_length/1024/1024,2),' MB') as data_size, concat(truncate(index_length/1024/1024,2),' MB') as index_size from information_schema.tables where TABLE_SCHEMA = '数据库名' order by data_length desc;…
查看某个表的磁盘占用量 select (data_length+index_length)/1024/1024 M from information_schema.tables where table_schema="db_name" and table_name='table_name'; 查看整个数据库的磁盘用量 select sum((data_length+index_length)/1024/1024) M from information_schema.tables whe…
#查看每个数据库所占磁盘大小 SELECT TABLE_SCHEMA AS "库名", , ) AS "表所占空间(MB)", , ) AS "索引所占空间(MB)", ,) AS "空间累计(MB)" FROM information_schema.`TABLES` GROUP BY `TABLE_SCHEMA`; #查看某个数据库各表所占磁盘大小 SELECT TABLE_NAME, , ) AS "DATA_…
use information_schema; -- 查询一个数据库存储大小 select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='database nane'; 85MB -- 查询一个表存储大小 select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where…
方法1.用 if 语句,如下例. 方法2.用case when then else 语句,用法如同if. mysql> select sum(if(id<500,1,0)),sum(if(id>=500 && id<1000,1,0)) from customer; +---------------------+---------------------------------+ | sum(if(id<500,1,0)) | sum(if(id>=…
//数据库表存储大小 select table_schema,table_name,table_rows,concat(round(data_length/1024/1024/1024,2),'GB') length from tables where table_schema='ERP' order by table_rows desc; //一台服务器传输到另一台服务器 路径写法 scp /home/table_t_user.sql root@115.29.249.149:/home //…
查看所有mysql数据库表和索引大小 mysql查看当前所有的数据库和索引大小 ,),' mb') as data_size, concat(,),'mb') as index_size from information_schema.tables group by table_schema order by data_length desc; mysql查看当前某个数据库和数据库下所有的表的大小 ,),' mb') as data_size, concat(,),' mb') as index…