mysql☞常用命令

阅读量: zyh 2020-09-11 15:53:04
Categories: > Tags:

查询库表占用空间

SELECT
    table_schema AS '数据库',
    table_name AS '表名',
    table_rows AS '记录数',
    TRUNCATE (data_length / 1024 / 1024 / 1024, 3) AS '数据容量(GB)',
    TRUNCATE (index_length / 1024 / 1024 / 1024 , 3) AS '索引容量(GB)',
	TRUNCATE (DATA_FREE / 1024 / 1024 / 1024, 3) AS '已占用空间但未使用(GB)'
FROM
    information_schema. TABLES
WHERE
    table_schema in ('new_data','megable_main','megable_active')
ORDER BY
    data_length DESC;