20 Eylül 2013 Cuma

List of Foreign Keys in Mysql

Following sql shows list of foreing keys in Mysql. You may require this information for foreign key manipulations, such as dropping a foreign key.

use INFORMATION_SCHEMA;

select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME,
REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from KEY_COLUMN_USAGE where
TABLE_NAME = '<table>';

You may require this information for foreign key manipulations, such as dropping a foreign key.

Resource: http://stackoverflow.com/questions/201621/how-do-i-see-all-foreign-keys-to-a-table-or-column 

Hiç yorum yok: