本文介绍了在MySQL中删除表是否也删除索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
文档中没有明确提及()。我问,因为我刚刚看到一个好奇的数据库迁移在一个Rails项目,开发人员删除所有的索引,然后删除表,这似乎是不必要的。
解决方案 $ p
但是,如果你有外键约束,如RESTRICT,可以确保与其他表的引用完整性,在删除或截断表之前删除这些键。
It's not explicitly mentioned in the documentation (http://dev.mysql.com/doc/refman/6.0/en/drop-table.html). I ask because I just saw a curious database migration in a Rails project where the developer was removing all the indexes before dropping the table, and that seemed unnecessary.
解决方案
Yes, it does.
However, if you have foreign key constraints such as RESTRICT that ensure referential integrity with other tables, you'll want to drop those keys prior to dropping or truncating a table.
这篇关于在MySQL中删除表是否也删除索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
08-23 02:29