tigrantv
3/9/2016 - 7:59 AM

Find all foreign keys to a table or column?

Find all foreign keys to a table or column?

SELECT 
  TABLE_NAME, COLUMN_NAME, CONSTRAINT_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
FROM
  INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE
  REFERENCED_TABLE_NAME = 'table_name';