This is a discussion on case insensitive primary key within the MySQL General forum forums, part of the MySQL category; --> Hi, My MySQL on Debian is on version "4.0.24_Debian-10sarge1-log". I have a varchar(255) as a primary key for a ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, My MySQL on Debian is on version "4.0.24_Debian-10sarge1-log". I have a varchar(255) as a primary key for a table. I have found the primary key case insensitive. Is this normal? This is not the behavior I prefer. Any help would be appreciated, thanks. Timothy |
| |||
| On 10/15/06, Timothy Wu <2huggie@gmail.com> wrote: > > Hi, hi My MySQL on Debian is on version "4.0.24_Debian-10sarge1-log". I have a > varchar(255) as a primary key for a table. I have found the primary key > case > insensitive. Is this normal? Yes, it's normal! To force mysql to use case-sensitive matching you should use BINARY in your comparison as follows: SELECT BINARY 'abc'='AbC' ; <- returns false SELECT 'abc'='AbC' ; <- returns true or you could even declare your field as binary! For more info: http://dev.mysql.com/doc/refman/5.0/...binary-op.html This is not the behavior I prefer. Any help > would be appreciated, thanks. > > Timothy > > -- http://www.openwebspider.org http://www.eviltime.com - " Time is what we want most, but what we use worst " |
| |||
| At 08:26 AM 10/15/2006, you wrote: >Hi, > >My MySQL on Debian is on version "4.0.24_Debian-10sarge1-log". I have a >varchar(255) as a primary key for a table. I have found the primary key case >insensitive. Is this normal? This is not the behavior I prefer. Any help >would be appreciated, thanks. > >Timothy Timothy, You can make the varchar column case sensitive by using the binary attribute or use the isstrcmp(value1,value2) for an exact match. See http://lists.mysql.com/mysql/170390 varchar(255) binary or select binary 'a'='A' ... Mike |
| ||||
| On 10/16/06, mos <mos99@fastmail.fm> wrote: > > > Timothy, > You can make the varchar column case sensitive by using the > binary > attribute or use the isstrcmp(value1,value2) for an exact match. > > See http://lists.mysql.com/mysql/170390 > varchar(255) binary > > or select binary 'a'='A' ... > > Mike > The binary attribute allows me to store the same entry with different caps, thanks. Timothy |