List:General Discussion« Previous MessageNext Message »
From:Alec.Cawley Date:February 10 2005 11:11am
Subject:Re: How to specify autoincrement primary key value
View as plain text  
"Denis Gerasimov" <denis.gerasimov@stripped> wrote on 10/02/2005 10:59:11:

> 
> Hello,
> 
> One simple question... AFAIK I can specify value for an autoincrement
> primary key (int) when inserting a record like this:
> 
> INSERT INTO `tablename` (`id`, `name`) VALUES (1, 'test')
> 
> But it doesn't work for id = 0. Why?
> 
> I would like to use some primary key values for special purpose, e.g. id 
0
> means root/default record and so on.
> Is that recommended? Are there any alternative ways?

Autoincrement starts from 1. That is the way it is, and cannot, I think, 
be changed.

I would advise against using autoincrement keys for "special" uses. This 
is muddling two different functions into one. Remeber that primary keys 
must be unique: if, at some time, you need to have more than one of a 
"special" value, you will be in trouble. The function of autoincrement 
keys is to assign unique record identifiers. Do not mix this with other 
tasks.

        Alec

Thread
How to specify autoincrement primary key valueDenis Gerasimov10 Feb
  • Re: How to specify autoincrement primary key valueAlec.Cawley10 Feb
RE: How to specify autoincrement primary key valueDenis Gerasimov10 Feb
  • Re: How to specify autoincrement primary key valueMartijn Tonies10 Feb
    • RE: How to specify autoincrement primary key valueDenis Gerasimov18 Feb