SELECT
CONCAT('ALTER TABLE ',TABLE_SCHEMA,'.',TABLE_NAME,' DROP FOREIGN KEY ',CONSTRAINT_NAME,' ;')
FROM
information_schema.TABLE_CONSTRAINTS c
WHERE
c.TABLE_SCHEMA='db_rule_dto_test' AND c.CONSTRAINT_TYPE='FOREIGN KEY';
SELECT
CONCAT('ALTER TABLE ',TABLE_SCHEMA,'.',TABLE_NAME,' DROP FOREIGN KEY ',CONSTRAINT_NAME,' ;')
FROM
information_schema.TABLE_CONSTRAINTS c
WHERE
c.TABLE_SCHEMA='db_rule_dto_test' AND c.CONSTRAINT_TYPE='FOREIGN KEY';
本文标题:删除数据库所有的外键
本文链接:https://www.haomeiwen.com/subject/rragnhtx.html
网友评论