gpt4 book ai didi

mysql 外键和索引

转载 作者:行者123 更新时间:2023-11-29 21:03:28 26 4
gpt4 key购买 nike

如果我有两张 table

user
-----------------
id integer PK
name varchar

address
----------------
id integer PK
user_id integer
city varchar

现在,如果 user.id <-> adress.user_id 之间存在一对多外键是否还需要在 user_id 列中创建索引以加速选择查询?

或者因为我创建了外键,所以我还隐式创建了一个索引,该索引将从 dmbs 中使用来加速查询?

最佳答案

索引为created automatically when creating an FK :

The index_name value is ignored if there is already an explicitly defined index on the child table that can support the foreign key. Otherwise, MySQL implicitly creates a foreign key index that is named according to the following rules ...

关于mysql 外键和索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37021498/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com