Unix Technical Forum

case insensitive primary key

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 ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 09:33 PM
Timothy Wu
 
Posts: n/a
Default case insensitive primary key

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 09:33 PM
Shen139
 
Posts: n/a
Default Re: case insensitive primary key

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 "

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 09:33 PM
mos
 
Posts: n/a
Default Re: case insensitive primary key

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 09:34 PM
Timothy Wu
 
Posts: n/a
Default Re: case insensitive primary key

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:49 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com