Created
March 17, 2016 03:14
-
-
Save ryanguill/7f496fe5ad5e81e1b1e6 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 | |
n.nspname | |
, c.relname | |
, c.relhaspkey | |
, sum(case when i.indisunique = 't' then 1 else 0 end) | |
FROM | |
pg_catalog.pg_class c | |
INNER | |
JOIN pg_namespace n | |
ON c.relnamespace = n.oid | |
AND n.nspname NOT IN ('information_schema', 'pg_catalog') | |
AND c.relkind='r' | |
LEFT OUTER | |
JOIN pg_index i on c.oid = i.indrelid | |
WHERE | |
c.relhaspkey = 'f' | |
group BY | |
n.nspname | |
,c.relname | |
,c.relhaspkey | |
having sum(case when i.indisunique = 't' then 1 else 0 end) = 0 | |
ORDER BY c.relhaspkey, c.relname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment