Question

J'ai un champ de type char(1) dans ma table de MySQL, qui peut en principe avoir que des valeurs m ou f. Son assemblage en cours est réglé sur ut8_unicode_ci. Je pensais que je devrais ou ne devrait pas modifier le classement à quelque chose plus simple comme le latin, car l'ensemble des caractères utf8 est jamais utilisé - que les caractères m ou f. Que ne change quelque chose?

Était-ce utile?

La solution

I doubt that it will make any measurable difference, but if m and f are the only possible values, then utf8_bin should produce exactly the same results as utf8_unicode_ci (or most other collation algorithms for that matter). And since that collation does a simple binary comparison it's bound to be the fastest one around.

Autres conseils

Collation is the rule that defines how the characters are supposed to be ordered. Imagine an alphabet sequence - A is 1st letter and Z is the last letter (in English). Collation is the rule that says that A is first and Z is last and it also helps define how characters are compared. In short - collation has nothing to do with anything in your case.

What you should do is set that field to tinyint, until MySQL comes up with boolean types later on. That way you'll bypass any charset issues that might arise at any point, although in your example they're not really what matters.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top