본문 바로가기

프로그래밍/DBMS

[Mysql] 테이블 명세서 쿼리

SELECT
  ORDINAL_POSITION AS `필드순번`,
  COLUMN_NAME AS `필드명`,
  COLUMN_TYPE AS `데이터 LENGTH`,
  IS_NULLABLE AS `NULL값여부`,
  COLUMN_KEY AS `KEY`,
  EXTRA AS `자동여부`,
  COLUMN_DEFAULT `기본값`,
  COLUMN_COMMENT AS `필드설명`
FROM
  INFORMATION_SCHEMA.COLUMNS
WHERE
  TABLE_SCHEMA = '데이터베이스이름'
  AND TABLE_NAME = '테이블이름'
ORDER BY
  TABLE_NAME, ORDINAL_POSITION