I have a large database with over 150 tables that I've recently been handed. I'm just wondering if there is an easy way to view all foreign key constraints for the entire DB instead of on a per-table basis.
You can use the INFORMATION_SCHEMA
tables for this. For example, the INFORMATION_SCHEMA TABLE_CONSTRAINTS
table.
Something like this should do it:
select *
from INFORMATION_SCHEMA.TABLE_CONSTRAINTS
where CONSTRAINT_TYPE = 'FOREIGN KEY'