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

查看mysql数据库和表所占用空间

时间:2016-09-05 17:31:42      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:mysql

1、数据库所占空间

SELECT CONCAT(TRUNCATE(SUM(data_length)/1024/1024,2),‘MB‘) AS data_size,
CONCAT(TRUNCATE(SUM(max_data_length)/1024/1024,2),‘MB‘) AS max_data_size,
CONCAT(TRUNCATE(SUM(data_free)/1024/1024,2),‘MB‘) AS data_free,
CONCAT(TRUNCATE(SUM(index_length)/1024/1024,2),‘MB‘) AS index_size
FROM information_schema.tables WHERE TABLE_SCHEMA = ‘数据库名‘;

 

 

2、表所占空间

SELECT CONCAT(TRUNCATE(SUM(data_length)/1024/1024,2),‘MB‘) AS data_size,
CONCAT(TRUNCATE(SUM(max_data_length)/1024/1024,2),‘MB‘) AS max_data_size,
CONCAT(TRUNCATE(SUM(data_free)/1024/1024,2),‘MB‘) AS data_free,
CONCAT(TRUNCATE(SUM(index_length)/1024/1024,2),‘MB‘) AS index_size
FROM information_schema.tables WHERE TABLE_NAME = ‘表名‘;


本文出自 “梦想照进现实” 博客,请务必保留此出处http://lookingdream.blog.51cto.com/5177800/1846346

查看mysql数据库和表所占用空间

标签:mysql

原文地址:http://lookingdream.blog.51cto.com/5177800/1846346

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