본문 바로가기

logs/database

mySql] 테이블, 컬럼 조회하기

* 테이블 조회


select @RN:=@RN+1 AS SN

  , a.table_name

  , a.table_comment

  from INFORMATION_SCHEMA.tables a, (SELECT @RN:=0) b

 where table_schema='스키마명';



* 테이블, 컬럼 조회


select if(b.ordinal_position='1',a.table_name,'') as table_name

  , if(b.ordinal_position='1',a.table_comment,'') as table_comment

  , b.ordinal_position

  , b.column_key

  , b.column_name

  , b.column_type

  , b.is_nullable

  , b.column_comment

  from INFORMATION_SCHEMA.tables a

  left outer join INFORMATION_SCHEMA.columns b

    on a.table_name = b.table_name

   and a.table_schema = b.table_schema

 where a.table_schema='스키마명'

 ;










반응형