1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > MySQL之查看表占用空间大小

MySQL之查看表占用空间大小

时间:2021-02-03 07:11:03

相关推荐

MySQL之查看表占用空间大小

文章目录

information_schema查看表大小

information_schema

在mysql中有一个默认的数据库information_schema,information_schema库下的表保存了MySQL服务器所有数据库的信息。如数据库名,数据库的表,表栏的数据类型与访问权限等。

查看表大小

use information_schema;

SELECT data_length, index_lengthFROM tablesWHERE table_schema = 'dbname'AND table_name = 'tablename'; 输出值的单位:Byte+-------------+--------------+ | data_length | index_length | +-------------+--------------+ | 166379520 | 235782144 | +-------------+--------------+

转为MB

SELECT CONCAT(ROUND(SUM(data_length / 1024 / 1024), 2), 'MB') AS data_length_MB,CONCAT(ROUND(SUM(index_length / 1024 / 1024), 2), 'MB') AS index_length_MBFROM tablesWHERE table_schema = 'dbname'AND table_name = 'tablename';

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。