postgresql 查询字段 信息

发布时间:2024年01月08日

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’表的字段信息,下面对各个属性进行解释。

文章来源:https://blog.csdn.net/cuisidong1997/article/details/135450928
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。