How do I see all foreign keys to a table or column?
down voteaccepted
|
For a Table:
For a Column:
Basically, we changed REFERENCED_TABLE_NAME with REFERENCED_COLUMN_NAME in the where clause. |
use INFORMATION_SCHEMA;
select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME,
REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from KEY_COLUMN_USAGE
where TABLE_SCHEMA = "<your_database_name>" and TABLE_NAME = "<your_table_name>"
and referenced_column_name is not NULL;
What Doesn't Kill Me Makes Me Stronger