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

混江龙づ霸主 提交于 2019-12-06 20:59:37

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/13338198/mysql-index-name-and-foreign-key-name-must-be-different-for-different-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!