본문 바로가기
여러가지/Database

[MySql & Mariadb] 데이터베이스 전체 용량 및 테이블 용량 확인하는 방법 !!

by 포스트it 2024. 8. 20.
728x90
반응형

[MySql & Mariadb] 데이터베이스 전체 용량 및 테이블 용량 확인하는 방법 !!

mariadb에서 각 테이블들이 사용되는 용량과 스키마들의 용량을 확인하는 쿼리입니다 !

테이블용량만 스키마 따로 입력해주시면 되고 나머지는 아래 쿼리 바로 사용하시면 됩니다 :)

# 각 테이블용량 확인

SELECT 
    table_schema AS `Database`, 
    table_name AS `Table`, 
    ROUND(((data_length + index_length) / 1024 / 1024), 2) AS `Size (MB)`
FROM 
    information_schema.TABLES
WHERE 
    table_schema = 'your_schema'
ORDER BY 
    (data_length + index_length) DESC;

 

# 각 스키마들의 용량

SELECT 
    table_schema AS `Database`, 
    ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS `Total Size (MB)`
FROM 
    information_schema.TABLES
GROUP BY 
    table_schema;

 

# 데이터베이스 총 용량

SELECT
    ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS `Total Database Size (MB)`
FROM
    information_schema.TABLES;
728x90
반응형

댓글