데이터 분석/SQL

Mysql 데이터베이스, 테이블 용량 조회하는 법

catloaf 2021. 12. 8. 09:27

1. 데이터 베이스 용량 조회

"bmwgs" => DB name임

 

SELECT table_schema "bmwgs",
SUM(data_length + index_length) / 1024 / 1024 "Size(MB)"
FROM information_schema.TABLES
GROUP BY table_schema;

2. 테이블 용량 조회

'car_model_keyword" => table name임

SELECT table_name AS 'car_model_keyword',
                 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 car_model_keyword
ORDER BY data_length DESC;

 

 

 

반응형