Created
July 26, 2019 06:53
-
-
Save hooopo/ecd007240775ca381f7765a1334447ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
kcu.table_name, | |
array_agg(kcu.column_name::text order by kcu.ordinal_position asc) 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 | |
and kcu.constraint_name = tco.constraint_name | |
where tco.constraint_type = 'PRIMARY KEY' | |
group by 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment