Wednesday, April 8, 2009

Sysobjects equivalent in PostgreSQL?

Foreign keys can be queried like this:

select t.constraint_name, t.table_name, t.constraint_type,
c.table_name, c.column_name
from information_schema.table_constraints t,
information_schema.constraint_column_usage c
where t.constraint_name = c.constraint_name
and t.constraint_type = 'FOREIGN KEY'
and c.table_name = 'mytable';

No comments: