1. 首页
  2. IT资讯

mysql查表空间大小的SQL语句

SQL语句如下: 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 = ‘databasename’; 例如查mysql数据库表空间大小: mysql> show databases; +——————–+ | Database | +——————–+ | information_schema | | db_shop | | mysql | | performance_schema | | test | +——————–+ 5 rows in set (0.52 sec) mysql> mysql> 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 = ‘mysql’; +———–+——————–+———–+————+ | data_size | max_data_size | data_free | index_size | +———–+——————–+———–+————+ | 0.51MB | 1938103992319.99MB | 0.00MB | 0.09MB | +———–+——————–+———–+————+ 1 row in set (1.49 sec) mysql>

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29578568/viewspace-2152801/,如需转载,请注明出处,否则将追究法律责任。

主题测试文章,只做测试使用。发布者:布吉卡,转转请注明出处:http://www.cxybcw.com/195470.html

联系我们

13687733322

在线咨询:点击这里给我发消息

邮件:1877088071@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

QR code