开发者

MySQL case sensitive foreign key for textual data

I have ISO 639-2 lang开发者_运维问答uage codes (eng, fre, hin, etc.) in english as primary key in my master table. This column is foreign key in may other tables. Now my issue is even though my master have only lower case values, due to human error some values were added in other tables with language id in mixed cases. Even though there was foreign key, it didn't prevent it from happening.

Now this is first time I am working in MySQL, previously I worked on Oracle and it applies case sensitivity to keys. What should be done to have same functionality in MySQL? Also what should be the column type?

Right now it is varchar(3). Should I convert it to something else? I am not going to use any like condition in any of the query, only = and in.


It happens because collation of collumn is case insensitive - something like latin1_swedish_ci change it to case sensitive collation - latin1_swedish_cs

ALTER TABLE t1 MODIFY col1 VARCHAR(3) CHARACTER SET latin1 COLLATE latin1_swedish_cs;

link text

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜