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” = ‘sys_org’
AND t1.relname = base.“table_name”
AND t2.attname = base.“column_name”
AND t1.oid = t2.attrelid
AND t2.attnum > 0;
以上查询的是’sys_org’表的字段信息,下面对各个属性进行解释。

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