我相信我找到了答案 - pg_class(可以加入pg_type ON pg_type.typrelid = pg_class.oid)有一个名为的列relkind提供:
r = ordinary table
i = index
S = sequence
v = view
c = composite type *** identifies free-standing composite type
t = TOAST table
此查询标识自定义(独立)类型:
select t.typname, t.typtype, t.typcategory, t.typrelid, c.relname, c.relkind
from pg_type t
left join pg_class c on c.oid = t.typrelid
where t.typtype = 'c' and c.relkind = 'c';
SELECT t.oid::regtype
FROM pg_type AS t
WHERE t.typtype = 'c'
AND t.typnamespace NOT IN
('pg_catalog'::regnamespace, 'pg_toast'::regnamespace)
AND NOT EXISTS (
SELECT 1 FROM pg_depend AS d
WHERE d.objid = t.oid
AND d.classid = 'pg_type'::regclass
AND d.refclassid = 'pg_class'::regclass
AND d.deptype = 'i');
我相信我找到了答案 -
pg_class
(可以加入pg_type ON pg_type.typrelid = pg_class.oid
)有一个名为的列relkind
提供:此查询标识自定义(独立)类型:
属于表的复合类型对
pg_depend
. 您只需排除此类类型: