Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- mysql 테이블 형식 추출 쿼리
- SELECT
- t1.table_name, ORDINAL_POSITION, column_name 'Column Name', COLUMN_TYPE 'COLUMN TYPE', column_key 'Key',
- case
- when is_nullable = 'YES' THEN 'Y'
- when is_nullable = 'NO' THEN 'N'
- END AS 'Null able',
- column_default 'Default Value', column_comment 'Comment',t1.table_comment,extra 'Extra'
- FROM
- (SELECT
- table_name, table_comment
- FROM
- information_schema.TABLES WHERE table_schema='데이터베이스 이름') t1,
- (SELECT
- table_name,ORDINAL_POSITION, column_name, COLUMN_TYPE,column_key, extra, is_nullable, column_default, column_comment
- FROM
- information_schema.COLUMNS WHERE table_schema='데이터베이스 이름') t2
- WHERE
- t1.table_name = t2.table_name
- ORDER BY
- t1.table_name, ordinal_position;
- -- mysql 테이블 추출 쿼리
- SELECT
- ORDINAL_POSITION '필드순번',
- COLUMN_NAME '필드명',
- DATA_TYPE '데이터 TYPE',
- COLUMN_TYPE '데이터 LENGTH',
- COLUMN_KEY 'KEY',
- IS_NULLABLE 'NULL값여부',
- EXTRA '자동여부',
- COLUMN_DEFAULT '디폴트값',
- COLUMN_COMMENT '필드설명'
- FROM
- `information_schema`.COLUMNS
- WHERE
- TABLE_SCHEMA = '데이터베이스 이름'
- AND TABLE_NAME = '테이블 명'
- ORDER BY
- TABLE_NAME, ORDINAL_POSITION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement