是否可以暂时禁用 MySQL 中的约束?
Is it possible to temporarily disable constraints in MySQL?
我有两个 Django 模型,每个模型都有一个指向另一个模型的外键.由于外键约束,删除模型的实例会返回错误:
I have two Django models, each with a foreign key to the other one. Deleting instances of a model returns an error because of the foreign key constraint:
cursor.execute("DELETE FROM myapp_item WHERE n = %s", n)
transaction.commit_unless_managed() #a foreign key constraint fails here
cursor.execute("DELETE FROM myapp_style WHERE n = %s", n)
transaction.commit_unless_managed()
是否可以暂时禁用约束并删除?
Is it possible to temporarily disable constraints and delete anyway?
Try DISABLE KEYS 或
SET FOREIGN_KEY_CHECKS=0;
确保
SET FOREIGN_KEY_CHECKS=1;
之后.
这篇关于如何在 MySQL 中临时禁用外键约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
分解表以按列进行透视(SQL、PYSPARK)Break down a table to pivot in columns (SQL,PYSPARK)(分解表以按列进行透视(SQL、PYSPARK))
使用 SparkSQL 删除 MySQL 表Dropping MySQL table with SparkSQL(使用 SparkSQL 删除 MySQL 表)
Spark在执行jdbc保存时给出空指针异常Spark giving Null Pointer Exception while performing jdbc save(Spark在执行jdbc保存时给出空指针异常)
使用 spark sql 在 sqlserver 上执行查询execute query on sqlserver using spark sql(使用 spark sql 在 sqlserver 上执行查询)
如何有效地使用窗口函数根据 N 个先前值来决定How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函数根据
Spark SQL/Hive 查询永远需要加入Spark SQL/Hive Query Takes Forever With Join(Spark SQL/Hive 查询永远需要加入)