码迷,mamicode.com
首页 > 数据库 > 详细

mysql 查看大表,查看个表占用大小

时间:2020-03-21 13:04:23      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:HERE   inf   truncate   情况   desc   size   schema   rom   bsp   

use information_schema;


-- 查看 各库 占用 大小
select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2), MB) as data_size,
concat(truncate(sum(index_length)/1024/1024,2),MB) as index_size
from information_schema.tables
group by TABLE_SCHEMA
order by data_length desc;

-- 查看某个库 各表 占用 情况
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 = ku_ming
group by TABLE_NAME
order by data_length desc;

-- 查看 某个库 某个表 占用 情况
select table_name,concat(round(sum(data_length/1024/1024),2),MB) as data
from tables where table_schema=ku_ming
and table_name=‘tablename;

 

mysql 查看大表,查看个表占用大小

标签:HERE   inf   truncate   情况   desc   size   schema   rom   bsp   

原文地址:https://www.cnblogs.com/angdh/p/12537447.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!