gpt4 book ai didi

MySQL 查询截断所有表而忽略所有约束?

转载 作者:可可西里 更新时间:2023-11-01 08:34:15 25 4
gpt4 key购买 nike

我想截断 mysql 数据库中表的所有行。

SET FOREIGN_KEY_CHECKS = 0; -- Disable foreign key checking.
-- Need MySQL Query to iterater/loop and truncate all the tables or delete all the rows of the -- table
SET FOREIGN_KEY_CHECKS = 1; -- Enable foreign key checking.

有人可以帮我查询一下吗?

谢谢。

最佳答案

因为你使用这个表的主键作为其他表中的外键。*从子表中删除值,然后尝试截断父表*

例如:国家表->国家ID(主键),名称
people table -> people id(主键), People name, country id(外键)

从 people 表中删除值,然后尝试截断 country 表:)

关于MySQL 查询截断所有表而忽略所有约束?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17994793/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com