0%

MySQL查看数据库和表的占用空间大小

1
2
3
4
5
6
7
SELECT
*
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = '{db_name}'
AND table_name = '{tab_name}';
1
2
3
4
5
6
7
SELECT
concat(round(sum( data_length / 1024 / 1024 ),2 ),'MB' )
FROM
information_schema.PARTITIONS
WHERE
table_schema = 'db_name'
AND table_name = 'tab_name';