How can I create index on the basis of column content first 4 letter?
如何根据列内容前4个字母创建索引?
For example I have a table having multiple fields, one field is having name country
, all Country name is in that table.
例如,我有一个包含多个字段的表,一个字段具有名称国家/地区,所有国家/地区名称都在该表中。
RANK COUNTRY
--------------------------
1 Qatar
2 Luxembourg
3 Singapore
4 Brunei Darussalam
5 Kuwait
6 Norway
7 United Arab Emirates
8 Switzerland
9 United States
10 * SAR
Now I want to do the indexing on Country
field. But I want the indexing on first 4 letter of that filed data.
现在我想在Country字段上进行索引。但我希望对该提交数据的前4个字母进行索引。
1 个解决方案
#1
1
This is called a "prefix" index:
这称为“前缀”索引:
INDEX(country(4))
But I don't recommend it. There are under 300 countries in this world; you may as well index the full strings.
但我不推荐它。这个世界上有不到300个国家;你也可以索引完整的字符串。
#1
1
This is called a "prefix" index:
这称为“前缀”索引:
INDEX(country(4))
But I don't recommend it. There are under 300 countries in this world; you may as well index the full strings.
但我不推荐它。这个世界上有不到300个国家;你也可以索引完整的字符串。