Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

WwWXxX, udp high ports, d-link extract firmware dsl-2750u, wwwwxxxxx.2G, yxxxcom, WWWXXX, ftp://192.168.100.100, wwwxxx 100, www.xxxcon, wwwxxx

Links

XODOX
Impressum

#1: Unique on non null entries but allowing multiple nulls

Posted on 2011-10-17 15:39:07 by PengYu.UT

Hi,

If I use "NULL UNIQUE" when I create a table, it seems that only one
NULL entry is allowed. Since NULL could mean unknown, in this case,
two unknowns are not the same and I want to allow multiple nulls but I
still want non null entries be unique. Is there a construct in mysql
that can create a table column like this?

--
Regards,
Peng

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Report this message

#2: Re: Unique on non null entries but allowing multiple nulls

Posted on 2011-10-17 16:13:46 by Jigal van Hemert

Hi,

On 17-10-2011 15:39, Peng Yu wrote:
> If I use "NULL UNIQUE" when I create a table, it seems that only one
> NULL entry is allowed. Since NULL could mean unknown, in this case,
> two unknowns are not the same and I want to allow multiple nulls but I
> still want non null entries be unique. Is there a construct in mysql
> that can create a table column like this?

From the documentation:
A UNIQUE index creates a constraint such that all values in the index
must be distinct. An error occurs if you try to add a new row with a key
value that matches an existing row. For all engines, a UNIQUE index
permits multiple NULL values for columns that can contain NULL.

Only for 5.0 there is the exception that the BDB storage engine does not
allow multiple NULL values in a column with a UNIQUE index.

--
Kind regards / met vriendelijke groet,

Jigal van Hemert.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Report this message