当前位置:   article > 正文

命令查询mysql表空间_mysql查表空间大小的SQL语句

mysql查看表空间命令

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/,如需转载,请注明出处,否则将追究法律责任。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/660072
推荐阅读
相关标签
  

闽ICP备14008679号