List:General Discussion« Previous MessageNext Message »
From:Johan De Meersman Date:January 26 2010 11:04am
Subject:Re: auto_increment without primary key in innodb?
View as plain text  
On Mon, Jan 25, 2010 at 10:08 PM, Yong Lee <yong.lee@stripped> wrote:

> yah, mysql only allows one auto increment field n that's used as the
> primary key in tables.  I don't think it has to be the primary key as
> long as it is a unique key i think that's okay.
>
> so u should be able to do : create table (myid int unsigned not null
> auto_increment....., unique key (myid));
>
> but this is effectively a primary key....
>

Only mostly true :-)

 It *is* the same for MyISAM, but for InnoDB the primary key is special, as
that is the one that stores the data inline (clustered index). Additional
unique keys will only contain a reference to the primary key value for the
record.




-- 
Bier met grenadyn
Is als mosterd by den wyn
Sy die't drinkt, is eene kwezel
Hy die't drinkt, is ras een ezel

Thread
auto_increment without primary key in innodb?Yang Zhang25 Jan
  • RE: auto increment without primary key in innodb?Tom Worster25 Jan
    • Re: auto_increment without primary key in innodb?Yang Zhang25 Jan
      • Re: auto_increment without primary key in innodb?Jaime Crespo Rinc√≥n25 Jan
      • Re: auto_increment without primary key in innodb?Paul DuBois25 Jan
  • Re: auto_increment without primary key in innodb?Yong Lee26 Jan
    • Re: auto_increment without primary key in innodb?Johan De Meersman26 Jan