Jslfl【软件开发技术笔记】

mysql truncate外键引用错误1701

有时要对表数据清空,并重置ID,用命令”truncate table tablename;”当操作的表被其它表外键引用过,会提示”1701 – Cannot truncate a table referenced in a foreign key constraint…”,就算引用表没有数据时也会有些错误,这时可以用命令来解决”SET foreign_key_checks=0″,操作完了要设置回检查状态”SET foreign_key_checks=1″

Comments are currently closed.