问题描述
为了在重复密钥更新时使用,我做了这样的事情:
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中创建索引时索引名的意义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!