Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
postgres: explore primary keys
SELECT my_id, COUNT(my_id)
FROM my_table
GROUP BY my_id
HAVING COUNT(my_id) > 1;
select table_name, table_schema from information_schema."tables"
where table_name not in (
select table_name from information_schema.table_constraints where constraint_type='PRIMARY KEY'
) and table_schema='public';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment