select
TABLE_CATALOG,
TABLE_SCHEMA,
TABLE_NAME,
TABLE_TYPE ,
ENGINE,
VERSION,
ROW_FORMAT,
TABLE_ROWS,
AVG_ROW_LENGTH,
DATA_LENGTH,
MAX_DATA_LENGTH,
INDEX_LENGTH,
DATA_FREE,
`AUTO_INCREMENT`,
CREATE_TIME,
UPDATE_TIME,
CHECK_TIME,
TABLE_COLLATION,
CHECKSUM,
CREATE_OPTIONS,
TABLE_COMMENT
from information_schema.tables
where TABLE_SCHEMA IN ('dbpld', 'dbplf', 'mysqltst');
SELECT table_name, table_rows
FROM information_schema.tables
WHERE TABLE_SCHEMA IN ('dbpld', 'dbplf', 'mysqltst') ORDER BY table_name;
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = SCHEMA()
AND TABLE_NAME = 't_order_detail'
ORDER BY ORDINAL_POSITION;
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = SCHEMA()
AND TABLE_NAME IN (
SELECT table_name
FROM information_schema. tables
WHERE TABLE_SCHEMA IN ('dbpld', 'dbplf', 'mysqltst') ORDER BY table_name
)
ORDER BY TABLE_NAME, ORDINAL_POSITION;
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS in_c
JOIN INFORMATION_SCHEMA.TABLES in_t ON (in_c.table_name = in_t.table_name)
WHERE in_t.TABLE_SCHEMA IN ('dbpld', 'dbplf', 'mysqltst')
MySql DDL 추출
- 데이터베이스 연결 프로그램을 이용하여 직접 DDL 추출 ( 드래그나 여러개 클릭으로 한번에 가능)
- mysqldump 이용하기
- mysqldump 사용법, MySQL | export DDL
mysqldump -u root -p all-databases --no-data > {FILE_NAME}.sql
: DDL 정보만 dump 하기
mysqldump -h db-60c3.pub-cdb.gov-ntruss.com -u future -p --no-data dbpld > dbpld.sql
: dbpld 라는 특정 데이터베이스의 DDL 만 가져오기