mysql中key索引吗_Mysql中创建索引的INDEX和KEY

2019独角兽企业重金招聘Python工程师标准>>>

6936d1565ae689371725cdb5fc51c415.png

一、问题

被问到,mysql为什么用key创建索引,而不是index。这个被难住了。

二、查一下

w3school的sql文档

关于key和index只有三个页面,primary key,foreign key和create index。

看来使用index是比较标准的语法。

stack overflow的帖子

mysql的官方文档

KEY is normally a synonym for INDEX. The key attribute PRIMARY KEY can also be specified as just KEY when given in a column definition. This was implemented for compatibility with other database systems.

这篇对话文章,也挺有意思:

http://discuss.fogcreek.com/joelonsoftware5/default.asp?cmd=show&ixPost=152398

In MySQL, KEY is equivalent to INDEX. It won't check for duplicates without UNIQUE in front of it.

Egor

Wednesday, June 16, 2004

Boy, they should really change the name or behavior then, because that's a *big* departure from the relational definition of "KEY".

Captain McFly

Wednesday, June 16, 2004

另外,我们使用index和key分别创建索引,导出的create syntax是一样的。

三、结论

结论:index和key没有区别(即使有区别,也可以忽略)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值