USE `TEST_DB` ;
SET @DATABASENAME = 'TEST_DB';
SELECT
t1.table_name AS '테이블명',
t1.table_comment AS '테이블 설명',
ORDINAL_POSITION AS '필드순번',
column_name '컬럼명',
COLUMN_TYPE 'Data Type',
COLUMN_KEY AS 'KEY',
extra AS '자동여부',
is_nullable 'Null값 여부',
column_default '디폴트값',
column_comment '컬럼 설명'
FROM
( SELECT table_name, table_comment
FROM information_schema.TABLES
WHERE table_schema=@DATABASENAME
) t1,
( SELECT table_name, column_name, COLUMN_TYPE, column_key, extra, is_nullable, column_default, column_comment, ordinal_position
FROM information_schema.COLUMNS
WHERE table_schema=@DATABASENAME
) t2
WHERE t1.table_name = t2.table_name
ORDER BY
t1.table_name, ordinal_position;
MySQL 테이블 명세를 위한 쿼리
2017. 1. 17. 22:23