What is the significance of the index name when creating an index in MySQL?

前端 未结 3 605
渐次进展
渐次进展 2020-12-10 01:28

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);

3条回答
  •  一整个雨季
    2020-12-10 01:49

    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

    Just think of index names like table names. You can just as easily make a table called 'blah'.

    CREATE TABLE blah (f1 int);
    

    But 'blah' isn't very helpful for future reference. Just be consistent. something like

    CREATE UNIQUE INDEX field_uniq on mytable(field);
    

    or

    CREATE INDEX field1_field2_inx on mytable(field1, field2);
    

提交回复
热议问题