What is the significance of the index name when creating an index in MySQL?(在MySQL中创建索引时索引名的意义是什么?)
问题描述
为了在重复密钥更新时使用,我做了这样的事情:
I've done something like this in order to use on duplicate key update
:
CREATE UNIQUE INDEX blah on mytable(my_col_to_make_an_index);
它工作得很好.我只是不确定索引名称的目的是什么——在这种情况下是等等".我读过的东西说要使用一个,但我不明白为什么.它似乎没有用于查询,但如果我导出架构,我可以看到它.
and its worked just fine. I'm just not sure what the purpose of the index name is -- in this case 'blah'. The stuff I've read says to use one but I can't fathom why. It doesn't seem to be used in queries, although I can see it if I export the schema.
那么……索引名称的作用是什么?如果它有助于 CREATE TABLE
中的行最终看起来像:
So ... what purpose does the index name serve? If it helps the line in the CREATE TABLE
ends up looking like:
UNIQUE KEY `clothID` (`clothID`)
推荐答案
索引名称用于为以后的命令引用索引.喜欢下降索引.
The index name is used to reference the index for future commands. Like drop index.
http://dev.mysql.com/doc/refman/5.0/en/drop-index.html
想想索引名,就像表名一样.您可以轻松制作一个名为blah"的表格.
Just think of index names like table names. You can just as easily make a table called 'blah'.
CREATE TABLE blah (f1 int);
但是blah"对于将来的参考并不是很有帮助.只要保持一致.类似的东西
But 'blah' isn't very helpful for future reference. Just be consistent. something like
CREATE UNIQUE INDEX field_uniq on mytable(field);
或
CREATE INDEX field1_field2_inx on mytable(field1, field2);
这篇关于在MySQL中创建索引时索引名的意义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在MySQL中创建索引时索引名的意义是什么?


- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01