当修改实体类的关联关系时,数据库的外键将被更新。频繁的修改可能导致外键更新遇到错误,此时可以清除外键后重新创建。
数据无价,操作需谨慎!
SELECT
concat( 'alter table ', table_schema, '.', table_name, ' DROP FOREIGN KEY ', constraint_name, ';' ) AS query_sql
FROM
information_schema.table_constraints
WHERE
constraint_type = 'FOREIGN KEY'
AND table_schema = 'wp_test';
本文由 新逸Cary 创作,如果您觉得本文不错,请随意赞赏
采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
原文链接:https://blog.xinac.cn/archives/mysql-clear-fk.html
最后更新:2020-07-06 15:28:51
Update your browser to view this website correctly. Update my browser now