赞
踩
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/15498/viewspace-2021424/,如需转载,请注明出处,否则将追究法律责任。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。