<참조> https://ryean.tistory.com/21

 

전체, 데이터베이스별, 테이블 용량 확인 쿼리

 

1. 전체 용량 조회 

 

SELECT ROUND(SUM(data_length+index_length)/1024/1024, 1) AS 'Used(MB)',
                 ROUND(SUM(data_free)/1024/1024, 1) AS 'Free(MB)'
FROM information_schema.tables;

 

2. 데이터베이스별 용량 조회

 

SELECT table_schema AS 'DatabaseName', ROUND(SUM(data_length+index_length)/1024/1024, 1) AS 'Size(MB)'
FROM information_schema.tables
GROUP BY table_schema
ORDER BY 2 DESC;

 

3. 테이블별 용량 (Table Size) 조회

 

SELECT table_name AS 'TableName',
                 ROUND(SUM(data_length+index_length)/(1024*1024), 2) AS 'All(MB)',
                 ROUND(data_length/(1024*1024), 2) AS 'Data(MB)',
                 ROUND(index_length/(1024*1024), 2) AS 'Index(MB)'
FROM information_schema.tables
GROUP BY table_name
ORDER BY data_length DESC;

 

 

반응형

+ Recent posts