判断表中是否存在该字段
SELECT
count(1)
FROM
(
SELECT
attname
FROM
pg_catalog.pg_attribute
WHERE
attstattarget = - 1
AND attrelid IN ( SELECT oid FROM pg_catalog.pg_class WHERE relname = '表名' )
) t
where attname='字段名'
获取字段类型
select t."type" from (SELECT
format_type ( a.atttypid, a.atttypmod ) AS type,
a.attname AS fname
FROM
pg_class AS c,
pg_attribute AS a
WHERE
c.relname = #{tableName}
AND a.attrelid = c.oid
AND a.attnum >0
) t
where t.fname=#{field}