반응형
1. 데이터베이스 테이블 개수 조회
SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'DB_NAME';
2. 특정 테이블 용량 확인
SELECT table_name AS 'TableName',
table_rows,
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)',
ROUND(SUM(data_length+index_length)/(1024*1024*1024), 2) AS 'All(GB)',
ROUND(data_length/(1024*1024*1024), 2) AS 'Data(GB)',
ROUND(index_length/(1024*1024*1024), 2) AS 'Index(GB)'
FROM information_schema.tables
WHERE table_schema = 'DB_NAME'
AND table_name = 'TABLE_NAME'
GROUP BY table_name
ORDER BY data_length DESC;
3. 전체 테이블별 크기 조회
SELECT table_name,
ROUND((data_length + index_length)/(1024),2) as 'Size(KB)',
ROUND((data_length + index_length)/(1024*1024),2) as 'Size(MB)',
ROUND((data_length + index_length)/(1024*1024*1024),2) as 'Size(GB)'
FROM information_schema.tables
WHERE table_schema = 'DB_NAME'
GROUP BY table_name
ORDER BY 2 DESC;
반응형
'MYSQL' 카테고리의 다른 글
Mysql 용량 없는 경우 Binlog (바이너리로그) 삭제하기 (0) | 2023.08.14 |
---|---|
MySQL 페이징 성능 개선 및 LIMIT 최적화 (0) | 2023.07.27 |
MySQL 슬로우쿼리(slow-query) 설정(확인) (0) | 2023.07.05 |
MySQL DB Collation 및 CharacterSet 변경 (0) | 2023.06.23 |
SQL 구문의 실행순서 (0) | 2023.06.14 |