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:
此时如果想删除和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:
上一篇: @Autowired自动注入失败