'table'에 해당되는 글 1건

 

Mysql 에서 Database 및 Table 이 사용하는 용량 확인하기.

 

Mysql database 를 사용함에 있어서 현재 사용되어지고 있는 DB 의 사용량과 Table 에 대한 사용량을

알아보는 방법에 대해서 알려드립니다.

 

1. Database 사용량 확인

 

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

 

이와같이 해주시면 전체 데이터베이스의 사용양이 나타나게 되며,

만약, 특정한 Database 에대한 용량만 보고자 한다면 다음과 같이 WHERE 조건을 주시면 됩니다.

 

SELECT table_schema "Database Name",
SUM(data_length + index_length) / 1024 / 1024 "Size(MB)"
FROM information_schema.TABLES
WHERE table_schema = 'yulwon_new'
GROUP BY table_schema;

 

 

 

 

 

2. table 사용량 확인

 

SELECT
concat(table_schema,'.',table_name),
concat(round(table_rows/1000000,2),'M') rows,
concat(round(data_length/(1024*1024*1024),2),'G') DATA,
concat(round(index_length/(1024*1024*1024),2),'G') idx,
concat(round((data_length+index_length)/(1024*1024*1024),2),'G') total_size,
round(index_length/data_length,2) idxfrac
FROM information_schema.TABLES;

 

만약 특정 테이블의 정보만을 원하신다면...


where table_name = '테이블명' ;

 

조건을 붙여주시면 됩니다.

 

SELECT
concat(table_schema,'.',table_name),
concat(round(table_rows/1000000,2),'M') rows,
concat(round(data_length/(1024*1024*1024),2),'G') DATA,
concat(round(index_length/(1024*1024*1024),2),'G') idx,
concat(round((data_length+index_length)/(1024*1024*1024),2),'G') total_size,
round(index_length/data_length,2) idxfrac
FROM information_schema.TABLES
where table_name = '테이블명';

 

이런식입니다.

 

블로그 이미지

슬픈외로움

개발이 어려워? 모든것엔 답이있다...

,