Descobrindo Primary Key de todas as tabelas no PostgreSQL
select kcu.table_schema,kcu.table_name, tco.constraint_name, kcu.ordinal_position as position, kcu.column_name as key_column from information_schema.table_constraints tco join information_schema.key_column_usage kcu on kcu.constraint_name = tco.constraint_name and kcu.constraint_schema = tco.constraint_schema where tco.constraint_type = 'PRIMARY KEY' order by kcu.table_schema, kcu.table_name, position;
Referência
Listando todas as primary keys
https://dataedo.com/kb/query/postgresql/list-all-primary-keys-and-their-columns