Last active
August 29, 2015 14:04
-
-
Save yujihamaguchi/ded69bbf53227eea1616 to your computer and use it in GitHub Desktop.
[Redshift] 主キー情報取得
This file contains hidden or 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 | |
nspname | |
,relname | |
,conname | |
,attnum | |
,attname | |
,conkey | |
FROM | |
pg_constraint r1 | |
,pg_namespace r2 | |
,pg_class r3 | |
,pg_attribute r4 | |
WHERE | |
contype = 'p' | |
AND conrelid = r3.oid | |
AND conrelid = r4.attrelid | |
AND r3.relnamespace = r2.oid | |
AND r4.attnum = ANY(r1.conkey) | |
AND nspname = 'wrk' | |
AND relname = 'x' | |
ORDER BY | |
1,2,3,4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment