MySQL

MySQL DB 용량 확인

하카데미 2022. 10. 26. 18:23

 

# DB별 용량 확인
select table_schema "Database", round(sum(data_length+index_length)/1024/1024,1) "MB" from information_schema.tables group by 1;

# 테이블별 용량 확인
SELECT
	concat(table_schema,'.',table_name) AS "table",
	concat(round(data_length/(1024*1024),2)," MB") AS data,
	concat(round(index_length/(1024*1024),2)," MB") AS idx,
	concat(round((data_length+index_length)/(1024*1024),2)," MB") AS total_size,
	round(index_length/data_length,2) idxfrac
FROM 
	information_schema.TABLES
WHERE 
	table_rows is not null;