728x90
반응형
DB 용량 확인
SELECT
table_schema, sum(data_length) /1024/1024 AS mb
FROM
information_schema.tables
GROUP BY
table_schema
ORDER BY
sum(data_length+index_length) DESC;
Table 사용 용량 확인
SELECT
table_name, engine, table_rows AS tbl_rows,
avg_row_length AS rlen,
floor((data_length+index_length)/1024/1024) AS allmb, #총용량
floor((data_length)/1024/1024) AS dmb, #사용 용량
floor((index_length)/1024/1024) AS imb #인덱스 용량FROM
information_schema.tables
WHERE
table_schema='commander'
ORDER BY
(data_length+index_length) DESC;
특정 데이터베이스에 모든 테이블 정보
SHOW TABLE STATUS FROM (데이터베이스명);
SHOW TABLE STATUS로 가져온 정보
- Name : 테이블 이름
- Type : 테이블 타입
- Row_format : 열 저장 형태 (Fixed, Dynamic, Compressed)
- Rows : 열의 수
- Avg_row_length : 열의 평균 길이
- Data_length : 데이타파일의 길이
- Max_data_length : 데이타파일의 최대길이
- Index_length : 인덱스 파일의 길이
- Data_free : 사용되지않는 bytes 에 할당된 수
- Auto_increment : 다음 자동증가 변수
- Create_time : 테이블이 생성된 시간
- Update_time : 데이타파일의 마지막 UPDATE 시간
- Check_time : 테이블의 마지막 체크시간
- Create_options : 테이블 생성시의 기타옵션
- Comment : 테이블 생성시의 명령어
DB 생성 이후 테이블 옮기기
SELECT concat('RENAME TABLE ',TABLE_SCHEMA,'.',TABLE_NAME,' TO ','새DB명.',TABLE_NAME,';')
FROM information_schema.tables
WHERE TABLE_SCHEMA LIKE '기존DB명';
728x90
반응형
'Database' 카테고리의 다른 글
[ MySQL ] MySQL 쿼리 기초: LIKE, WHERE, ORDER BY, COUNT, JOIN 사용법 (0) | 2024.11.25 |
---|---|
[ MySQL ] 파일시스템에 따른 최대 DB 용량 (1) | 2024.11.18 |
[ MySQL ] my.ini 파일 성능개선 (2) | 2024.11.17 |
[ MySQL ] 백업 방법 (1) | 2024.11.16 |