在MySQL中创建索引时索引名称的意义是什么? [英] What is the significance of the index name when creating an index in MySQL?

查看:1063
本文介绍了在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);

它的工作正常。我只是不确定索引名称的用途是什么 - 在这种情况下'blah'。我读过的东西说要用一个,但我无法理解为什么。它似乎没有在查询中使用,虽然我可以在导出模式时看到它。

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中创建索引时索引名称的意义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆