programing

Mysql 목록 표 및 크기 - 크기순 정렬

fastcode 2023. 8. 28. 22:15
반응형

Mysql 목록 표 및 크기 - 크기순 정렬

mysql의 크기를 기준으로 데이터베이스 순서의 모든 테이블을 나열하는 쿼리는 무엇입니까?

해보세요...

SELECT TABLE_NAME, table_rows, data_length, index_length, 
round(((data_length + index_length) / 1024 / 1024),2) "Size in MB"
FROM information_schema.TABLES WHERE table_schema = "schema_name"
ORDER BY (data_length + index_length) DESC;

참고: 교체schema_name위에는 데이터베이스 이름이 있습니다.

mysql 클라이언트에서 다음 쿼리 실행

SELECT table_name AS "Tables", 
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" 
FROM information_schema.TABLES 
WHERE table_schema = "$DB_NAME"
ORDER BY (data_length + index_length) DESC;

information_schema 데이터베이스에서 다음 쿼리를 실행합니다.

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

언급URL : https://stackoverflow.com/questions/14569940/mysql-list-tables-and-sizes-order-by-size

반응형