时间:2021-07-01 10:21:17 帮助过:26人阅读
1.查找数据库的外键约束名
SELECT a.CONSTRAINT_NAME,b.TABLE_NAME from information_schema.REFERENTIAL_CONSTRAINTS a,information_schema.TABLES b WHERE a.TABLE_NAME=b.TABLE_NAME AND b.TABLE_SCHEMA = ‘test‘;
2.删除外键约束
select CONCAT(‘alter table ‘, b.TABLE_NAME, ‘ drop foreign key ‘, a.CONSTRAINT_NAME,‘;‘) from information_schema.REFERENTIAL_CONSTRAINTS a,information_schema.TABLES b WHERE a.TABLE_NAME=b.TABLE_NAME AND b.TABLE_SCHEMA = ‘test‘;
本文出自 “笔记” 博客,请务必保留此出处http://sunflower2.blog.51cto.com/8837503/1655038
mysql--SQL语句
标签:foreign 数据库