是否有可能一次删除所有的外键约束在MySQL 5中? [英] Is it possible to drop all foreign key constraints on a table at once in mySQL 5?

查看:150
本文介绍了是否有可能一次删除所有的外键约束在MySQL 5中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MySQL 5中,有没有办法使用一个SQL语句删除表中的所有外键约束,而不用名字来引用它们?



我正在编写一个数据库更新脚本,不幸的是,有些网站使用错误的名称创建了约束。我试图避免从数据库中获取实际的约束名称,并将它们插回SQL语句中。

解决方案

你可以肯定地选择*表格到一个临时表格,删除并重新创建,然后复制回来。


In mySQL 5, is there a way to drop all foreign key constraints on a table with one SQL statement without referring to them by name?

I'm writing a DB update script, and unfortunately some of the sites had constraints created with "wrong" names. I'm trying to avoid going in and getting the actual constraint names from the DB and inserting them back into SQL statements.

解决方案

You can surely select * the table to a temp table, drop and recreate it, then copy back.

这篇关于是否有可能一次删除所有的外键约束在MySQL 5中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆