Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. -- mysql 테이블 형식 추출 쿼리
  2.  
  3. SELECT
  4. t1.table_name, ORDINAL_POSITION, column_name 'Column Name', COLUMN_TYPE 'COLUMN TYPE', column_key 'Key',
  5. case
  6. when is_nullable = 'YES' THEN 'Y'
  7. when is_nullable = 'NO' THEN 'N'
  8. END AS 'Null able',
  9. column_default 'Default Value', column_comment 'Comment',t1.table_comment,extra 'Extra'
  10. FROM
  11. (SELECT
  12. table_name, table_comment
  13. FROM
  14. information_schema.TABLES WHERE table_schema='데이터베이스 이름') t1,
  15. (SELECT
  16. table_name,ORDINAL_POSITION, column_name, COLUMN_TYPE,column_key, extra, is_nullable, column_default, column_comment
  17. FROM
  18. information_schema.COLUMNS WHERE table_schema='데이터베이스 이름') t2
  19. WHERE
  20. t1.table_name = t2.table_name
  21. ORDER BY
  22. t1.table_name, ordinal_position;
  23.  
  24. -- mysql 테이블 추출 쿼리
  25. SELECT
  26. ORDINAL_POSITION '필드순번',
  27. COLUMN_NAME '필드명',
  28. DATA_TYPE '데이터 TYPE',
  29. COLUMN_TYPE '데이터 LENGTH',
  30. COLUMN_KEY 'KEY',
  31. IS_NULLABLE 'NULL값여부',
  32. EXTRA '자동여부',
  33. COLUMN_DEFAULT '디폴트값',
  34. COLUMN_COMMENT '필드설명'
  35. FROM
  36. `information_schema`.COLUMNS
  37. WHERE
  38. TABLE_SCHEMA = '데이터베이스 이름'
  39. AND TABLE_NAME = '테이블 명'
  40. ORDER BY
  41. TABLE_NAME, ORDINAL_POSITION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement