欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

mysql 找出外键等约束

程序员文章站 2022-10-08 21:31:53
找出employee表的所有外键约束 Result: 此时如果想删除和posId相关的外键,只需要 找出以employee为REFERENCED_TABLE的所有约束 Result: ......

找出employee表的所有外键约束

select
table_name,column_name,constraint_name, referenced_table_name,referenced_column_name
from information_schema.key_column_usage
where constraint_schema ='vhr' and
table_name = 'employee';

result:
mysql 找出外键等约束

此时如果想删除和posid相关的外键,只需要 alter table employee drop foreign key employee_ibfk_3;

找出以employee为referenced_table的所有约束

select
table_name,column_name,constraint_name, referenced_table_name,referenced_column_name
from information_schema.key_column_usage
where constraint_schema ='vhr' and
referenced_table_name = 'employee';

result:
mysql 找出外键等约束