Get list of all foreign key constraints.
Posted by sergey - 05/02/10 at 02:02:47 pmHere is the way i do this -
SELECT conname,
t.relname AS TABLE,
tf.relname AS ftable,
a.attname AS field,
af.attname AS ffield
FROM pg_constraint c,
pg_attribute a,
pg_attribute af,
pg_stat_user_tables t,
pg_stat_user_tables tf
WHERE c.contype='f'
AND c.conkey[1]=a.attnum
AND c.conrelid=a.attrelid
AND c.confkey[1]=af.attnum
AND c.confrelid=af.attrelid
AND t.relid=c.conrelid
AND tf.relid=c.confrelid
February 5, 2010 | In Uncategorized |
No Comments yet »
RSS feed for comments on this post. TrackBack URI
Leave a comment