postgresql 查询表中字段详细信息的方法

SELECT
base.“column_name”,
col_description ( t1.oid, t2.attnum ),
base.udt_name,
COALESCE(character_maximum_length, numeric_precision, datetime_precision),
(CASE
WHEN ( SELECT t2.attnum = ANY ( conkey ) FROM pg_constraint WHERE conrelid = t1.oid AND contype = ‘p’ ) = ‘t’
THEN 1 ELSE 0
END )
FROM
information_schema.COLUMNS base,
pg_class t1,
pg_attribute t2
WHERE
base.“table_name” = ‘tl_34G_20230528’
AND t1.relname = base.“table_name”
AND t2.attname = base.“column_name”
AND t1.oid = t2.attrelid
AND t2.attnum > 0;

你可能感兴趣的:(postgresql,数据库)