2

我有一个使用 phpMyAdmin 管理的数据库。我有一个表来保存verb tenseverb. 它看起来如下:

Column | Type        | Collation         |  Attributes | Null | Default | Extra
-------+-------------+-------------------+-------------+------+---------+------
form   | varchar(50) | latin1_swedish_ci |             | No   |         |
verb   | varchar(50) | latin1_swedish_ci |             | Yes  | NULL    |

我创建并索引以获得更快的访问:

Keyname     | Type  | Unique | Packed | Column | Cardinality | Collation | Null | Comment
------------+-------+--------+--------+--------+-------------+-----------+------+--------
verbs_index | BTREE | Yes    | No     | form   | 1           | A         |      |
            |       |        |        | verb   | 1           | A         | YES  |

这样做的目的是在动词及其所有动词时态 ( form) 之间建立关联,但是当我尝试插入一对带有重音的( form, ) 时,如果没有重音的形式已经存在,就会出现问题。verb这些与 MySql 相同的话,我得到了错误:

键“verbs_index”的重复条目“form-verb”。

我想插入:

insert into verbs values('o','verb1'); (without accent)
insert into verbs values('ó','verb1'); (with accent)

我一直在看整理的东西,我已经尝试过每一个latinand utf8

4

1 回答 1

1

“不区分大小写”排序规则将比较忽略任何变化的字符串。当然是这种情况。但它也会忽略变音符号。例如,o, O,Ôò被认为是相等的。

要了解系统上可用的排序规则,请使用SHOW COLLATION

mysql> SHOW COLLATION;
+----------------------+----------+-----+---------+----------+---------+
| Collation            | Charset  | Id  | Default | Compiled | Sortlen |
+----------------------+----------+-----+---------+----------+---------+
[...]
| latin1_german1_ci    | latin1   |   5 |         | Yes      |       1 |
| latin1_swedish_ci    | latin1   |   8 | Yes     | Yes      |       1 |
| latin1_danish_ci     | latin1   |  15 |         | Yes      |       1 |
| latin1_german2_ci    | latin1   |  31 |         | Yes      |       2 |
| latin1_bin           | latin1   |  47 |         | Yes      |       1 |
| latin1_general_ci    | latin1   |  48 |         | Yes      |       1 |
| latin1_general_cs    | latin1   |  49 |         | Yes      |       1 |
| latin1_spanish_ci    | latin1   |  94 |         | Yes      |       1 |
| latin2_czech_cs      | latin2   |   2 |         | Yes      |       4 |
| latin2_general_ci    | latin2   |   9 | Yes     | Yes      |       1 |
| latin2_hungarian_ci  | latin2   |  21 |         | Yes      |       1 |
| latin2_croatian_ci   | latin2   |  27 |         | Yes      |       1 |
[...]

告诉您要将表格排序规则更改为哪个latin1_general_cs_cs区分大小写 - 以及大小写+重音等等):

mysql> ALTER TABLE verbs COLLATE latin1_general_cs;
于 2013-06-25T18:50:50.917 回答