《mysql找出外键等约束》由会员分享,可在线阅读,更多相关《mysql找出外键等约束(2页珍藏版)》请在金锄头文库上搜索。
mysql 找出外键等约束找出employee表的所有外键约束selectTABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAMEfrom INFORMATION_SCHEMA.KEY_COLUMN_USAGEwhere CONSTRAINT_SCHEMA =#39;vhr#39; ANDTABLE_NAME = #39;employee#39;Result:此时如果想删除和posId相关的外键,只需要 alter table employee drop foreign key employee_ibfk_3;找出以employee为REFERENCED_TABLE的所有约束selectTABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAMEfrom INFORMATION_SCHEMA.KEY_COLUMN_USAGEwhere CONSTRAINT_SCHEMA =#39;vhr#39; ANDREFERENCED_TABLE_NAME = #39;employee#39;Result: