with res_table as (
SELECT
table_name,replace(replace(trim(obj_description ( oid, ‘pg_class’ ) ) ,chr(13),’’),chr(10),’’) as table_ms
FROM
information_schema.tables t1, pg_class t2
WHERE
table_schema = ‘east_por’
AND t1.table_name = t2.relname
)
SELECT res_table.*, a.attname as 属性编码,replace(replace(trim(col_description(a.attrelid,a.attnum)) ,chr(13),’’),chr(10),’’)
as 属性描述,format_type(a.atttypid,a.atttypmod) as 数据类型 ,
case a.attnotnull when ‘t’ then ‘是’ else ‘否’ end as 是否非空
FROM pg_class as c,pg_attribute as a ,res_table
where c.relname = res_table.table_name AND c.relname = ‘mdr_eastcx_djglzxxb’ and a.attrelid = c.oid and a.attnum>0 ORDER BY res_table.table_name