select tb.schemaname as 스키마명
,tb.relname as 테이블명
,tb_dc.description as 테이블설명
,col.attname as 컬럼명
,col.attnum as 컬럼순서
,col_dc.description as 컬럼설명
,col_type.data_type as 컬럼데이터타입
,col_type.character_maximum_length as len
from (select *
from PG_STAT_ALL_TABLES
where RELNAME = 'table_name'
and schemaname='schema_name') tb
left join PG_DESCRIPTION tb_dc
on tb_dc.OBJSUBID = 0
and tb.RELID = tb_dc.OBJOID
left join PG_ATTRIBUTE col
on tb.relid=col.ATTRELID
left join PG_DESCRIPTION col_dc
on col_dc.OBJSUBID <> 0
and tb.RELID = col_dc.OBJOID
and col_dc.OBJOID = col.ATTRELID
and col_dc.OBJSUBID = col.ATTNUM
left join INFORMATION_SCHEMA.COLUMNS col_type
on col_type.table_schema=tb.schemaname
and col_type.table_name=tb.relname
and col_type.column_name=col.attname
and col_type.ordinal_position=col.attnum
where col.attstattarget ='-1'
order by col.attnum;