MySQL索引名称和外键名称对于不同的表必须不同? [英] MySQL index name and foreign key name must be different for different tables?

查看:1023
本文介绍了MySQL索引名称和外键名称对于不同的表必须不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如,

两个表都具有属于第三个表(配置文件)的相同字段(profile_id)。所以我想让profile_id索引并将其限制为一个外键。

这两个表中的索引名称是否可以命名为profile_id_idx?



和profile_id_fk作为外键的名字呢?

解决方案

外键名称在所有数据库的所有表中必须是唯一的。索引名称可以在不同的表格中重复使用。


MySQL index name and foreign key name must be different for different tables?

For example,

Two tables both have the same field(profile_id) which are belonging to a third table(profiles). So I want to make the profile_id indexed and constrain it as a foreign key.

Could the index name be named "profile_id_idx" in both tables?

And "profile_id_fk" as name of foreign key for both too?

解决方案

Foreign Key names must be unique across all tables in all databases. Index names may be re-used in different tables.

这篇关于MySQL索引名称和外键名称对于不同的表必须不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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