Ver CONSTRAINTS postgres

PHOTO EMBED

Mon Jun 14 2021 17:06:09 GMT+0000 (Coordinated Universal Time)

Saved by @janicama #sql #postgres

select pgc.conname as constraint_name,
       ccu.table_schema as table_schema,
       ccu.table_name,
       ccu.column_name,
       pgc.* as definition
from pg_constraint pgc
join pg_namespace nsp on nsp.oid = pgc.connamespace
join pg_class  cls on pgc.conrelid = cls.oid
left join information_schema.constraint_column_usage ccu
          on pgc.conname = ccu.constraint_name
          and nsp.nspname = ccu.constraint_schema
where contype ='c'
order by pgc.conname;
content_copyCOPY