(snip)

>>>>
>>>> Does creating a primary key
>>>> on an int immediatly involve this one to be not null, and to
>>>> auto-increment?
>>>
>>>
>>>
>>> NOT NULL - yes, but if you want to have AUTO_INCREMENT column you
>>> should declare it as AUTO_INCREMENT.
>>
>>
>> Thank you very much for your reply.
>> But I read that a PRIMARY KEY is a "globally unique identifier" for a
>> table. As it is an identifier, it should never be null (ok, that's
>> what you said), and it should be unique... Then, if I don't set
>> AUTO_INCREMENT to my column ID, it still should be unique, and then
>> increment itself... No?
>
>
> Not all unique identifiers are computer-generated.  If you leave off
> AUTO_INCREMENT but still make it a primary key, uniqueness will be
> enforced on whatever the application(s) enter(s) as the value, but
> nothing will be plugged in.
>
> Bruce Feist
>
>
>>
>Ok, I'm not sure Iunderstood the real (technical) reason, but I
>understood that I had to use the AUTO_INCREMENT to be sure of a nice
>functionning of my database.
>Thank you very much all.

Let me give it a try. The primary key is *required* to be NOT NULL because the
value in the key *must* identify one and only one record in the table. If you
don't want to manually insert UNIQUE values in the ID column to accomplish this,
for example, in the mysql client, or by some other method such as an application
that writes data to the table, then using an AUTO_INCREMENT column attribute
will *enforce* the necessary uniqueness that a primary key requires. It is this
way be design and definition.




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to