01.MySQL
[MySQL]테이블별 용량 산정
redkite
2012. 12. 19. 15:41
-- 스키마 테이블 용량 조회
SELECT CONCAT(table_schema,'.',table_name),
CONCAT(ROUND(table_rows/1000000,2),'M') ROWS,
CONCAT(ROUND(data_length/(1024*1024),2),'M') DATA,
CONCAT(ROUND(index_length/(1024*1024),2),'M') idx,
CONCAT(ROUND((data_length+index_length)/(1024*1024),2),'M') total_size,
ROUND(index_length/data_length,2) idxfrac
FROM
information_schema.TABLES
WHERE
Table_schema='cheju_ib20'
-- 스키마 테이블 건수 조회
SELECT COUNT(*) FROM information_schema.TABLES WHERE Table_schema='cheju_ib20'
-- 스키마 테이블 용량만 조회
SELECT CONCAT(table_schema,'.',table_name),
CONCAT(ROUND((data_length+index_length)/(1024*1024),2),'M') total_size
FROM
information_schema.TABLES
WHERE
Table_schema='cheju_ib20'