DB/MYSQL

[ MYSQL ] 컬럼 구조 확인

HEON.D 2021. 11. 17. 16:27
SELECT
	TABLE_NAME AS 'table_name',
	ORDINAL_POSITION AS 'no',
	COLUMN_NAME AS 'field_name',
	COLUMN_COMMENT AS 'comment',
	COLUMN_TYPE AS 'type',
	COLUMN_KEY AS 'KEY',
	IS_NULLABLE AS 'NULL',
	EXTRA AS 'auto',
	COLUMN_DEFAULT 'default'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = '데이터베이스명'
ORDER BY TABLE_NAME, ORDINAL_POSITION;
SELECT
   t1.table_name, t1.table_comment, column_name, data_type, column_type, column_key, is_nullable, column_default, extra, column_comment
FROM
   (SELECT table_name, table_comment FROM information_schema.TABLES WHERE table_schema='데이터베이스명') t1,
   (SELECT table_name, column_name, data_type, column_type, column_key, is_nullable, column_default, extra, column_comment, ordinal_position FROM information_schema.COLUMNS WHERE table_schema='데이터베이스명') t2
WHERE t1.table_name = t2.table_name
ORDER BY t1.table_name, ordinal_position;

'DB > MYSQL' 카테고리의 다른 글

[ MYSQL ] RDS time_zone 변경  (0) 2021.11.19
[ MYSQL ] Timezone 확인  (0) 2021.11.19
[ MYSQL ] DATETIME Null값 체크  (0) 2021.10.21
[ MYSQL ] WHERE 를 통한 DELETE 안될때  (0) 2021.09.25
[ MYSQL ] 테이블 복제  (0) 2021.09.07