use information_schema
如果想看指定数据库中的数据表,可以用如下语句:
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='AAAA' and table_name='BBBB'
如果想看数据库中每个数据表的,可以用如下语句:
SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS,concat(round((DATA_LENGTH+INDEX_LENGTH)/1024/1024,2), 'MB') as data FROM TABLES WHERE TABLE_SCHEMA='AAAA'
输出:
mysql>show databases+--------------------+
| Database |
+--------------------+
| information_schema |
| hnmcc |
| hnmcc_ecp |
| hnmcc_push |
| hnmcc_sso |
| mysql |
| percona|
| performance_schema |
| test |
+--------------------+
9 rows in set (0.00 sec)
// 使用mysql自带管理表information_schema.
mysql>use information_schema;
mysql>select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='hnmcc' and table_name='l_log_20160102'
+-----------+
| data |
+-----------+
| 4803.00MB |
+-----------+
1 row in set (0.00 sec)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)