SELECT DISTINCT
'base table' AS type,
constraint_column_usage.table_schema AS schema_name,
constraint_column_usage.table_name AS parent_name,
constraint_column_usage.constraint_name
FROM
information_schema.constraint_column_usage
WHERE table_schema NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL)
UNION select
'base table' AS type,
n.nspname as table_schema,
c.relname as table_name,
o.conname as constraint_name
from pg_constraint o inner join pg_class c on c.oid = o.conrelid
inner join pg_namespace AS n on c.relnamespace=n.oid
inner join pg_authid AS a ON n.nspowner=a.oid
where o.contype in ('x')
and (n.nspname='public' OR a.rolname<>'postgres')
UNION SELECT
'domain' AS type,
constraint_schema,
domain_name,
constraint_name
FROM Information_schema.domain_constraints
WHERE constraint_schema NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL)
ORDER BY constraint_name ASC;