At 15:20 +0200 4/26/05, Jigal van Hemert wrote:
>From: "Jay Blanchard"
>> Since NULL is the absence of a value and PRIMARY keys must have a value
>> a NULL column cannot be included as a portion of a PRIMARY key. AFAIK
>> this is the case with every RDBMS out there. Asking the development team
>> might get you a more informative response.
>> There is a vast difference between a zero value, blank value and NULL
>> (absence of value).
>The situation is pretty challenging:
>- because of high concurrency and huge tables I need to use InnoDB
>- InnoDB really needs a PRIMARY key for fast results
>- a PRIMARY key does not allow NULL values as part of the key
>Anyhow, we something to think about...
A primary key absolutely forbids duplicate values.
Indexes created with the UNIQUE keyword do not allow duplicates, except
for the special case that multiple NULL values are allowed.
Such a unique index therefore cannot be a primary key. However, for the
purposes you describe above, it sounds like the solution is simply to
define your columns as allowing NULL, and to create your index using UNIQUE
rather than PRIMARY KEY.
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com