Problem
mysql删除主键重复ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key
Analysis
若一个table 中的某个column是其他table的foreign key,那么,就不能使用对该table 使用truncate
或者drop
SQL命令。
Solution
执行以下语句可以执行成功
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE TABLE tableName;
SET FOREIGN_KEY_CHECKS=1;
Reference
FEATURED TAGS
algorithm
algorithmproblem
architecturalpattern
architecture
aws
c#
cachesystem
codis
compile
concurrentcontrol
database
dataformat
datastructure
debug
design
designpattern
distributedsystem
django
docker
domain
engineering
freebsd
git
golang
grafana
hackintosh
hadoop
hardware
hexo
http
hugo
ios
iot
java
javaee
javascript
kafka
kubernetes
linux
linuxcommand
linuxio
lock
macos
markdown
microservices
mysql
nas
network
networkprogramming
nginx
node.js
npm
oop
openwrt
operatingsystem
padavan
performance
programming
prometheus
protobuf
python
redis
router
security
shell
software testing
spring
sql
systemdesign
truenas
ubuntu
vmware
vpn
windows
wmware
wordpress
xml
zookeeper