Skill/postgreSQL
postgresql] column명과 type조회
진열사랑
2024. 9. 20. 11:27
select C.table_name
,C.column_name
,C.data_type
,C.numeric_precision
,C.numeric_scale
,PD.DESCRIPTION
from INFORMATION_SCHEMA.COLUMNS C
, PG_STAT_USER_TABLES PS
, PG_DESCRIPTION PD
, PG_ATTRIBUTE PA
WHERE 1=1
AND PS.SCHEMANAME IN ('sppdb', 'spsdb')
AND PS.RELID = PD.OBJOID
AND PD.OBJSUBID != 0
AND PD.OBJOID = PA.ATTRELID
AND PD.OBJSUBID = PA.ATTNUM
AND C.TABLE_NAME = PS.RELNAME
AND C.COLUMN_NAME = PA.ATTNAME
and (C.column_name like '%fee%'
or C.column_name like '%amount%'
or C.column_name like '%vat%')
and C.numeric_precision < 10