Mysql中创建索引的INDEX和KEY
2016-04-21 00:00
411 查看
摘要: 结论:index和key没有区别(即使有区别,也可以忽略)
关于key和index只有三个页面,primary key,foreign key和create index。
看来使用index是比较标准的语法。
stack overflow的帖子
mysql的官方文档
这篇对话文章,也挺有意思:
http://discuss.fogcreek.com/joelonsoftware5/default.asp?cmd=show&ixPost=152398
另外,我们使用index和key分别创建索引,导出的create syntax是一样的。
一、问题
被问到,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没有区别(即使有区别,也可以忽略)相关文章推荐
- MySQL中的integer 数据类型
- MySQL存储过程
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- source命令执行SQL脚本文件
- MySQL创建用户及权限控制
- MySQL管理数据表
- linux下mysql添加用户
- mysql procedure
- mysql触发器
- MySQL 备份和恢复策略
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- MySQL数据的导出、导入(mysql内部命令:mysqldump、mysql)
- mysql数据行转列
- Linux下修改MySQL编码的方法
- MySQL Server 日志
- MySQL 安全事宜
- MySQL 备份与恢复