728x90
1. 데이터베이스 별 용량 조사
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;
2. 테이블 별 용량 조사
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;
3. 전체 용량 조사
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;
참조
반응형
'💾 Data > SQL' 카테고리의 다른 글
[SQL] 테이블 생성 (CREATE) (0) | 2023.09.12 |
---|---|
[SQL] 테이블 변경 (ALTER) (0) | 2023.08.31 |
[DB] 파티션 (Partition) (0) | 2023.06.08 |
[SQL] 프로시저와 함수 (0) | 2023.05.26 |
[MySQL] 데이터 타입 변환하기 (0) | 2023.05.18 |