List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:August 11 1999 4:23pm
Subject:Re: pri key auto_increment problem
View as plain text  
Benjamin Pflugmann wrote:
> 
> Hi.
> 
> On Tue, Aug 10, 1999 at 03:05:40PM -0500, archiver@stripped wrote:
> > This message was sent from Geocrawler.com by "Brent Edwards"
> <wbe@stripped>
> > Be sure to reply to that address.
> >
> > I would like to create a multiple column primary key, and one of the columns be
> auto_increment.  Here is my table create statements:
> > mysql> create table Problem (
> >     -> Subscriber_ID numeric(7,0) NOT NULL,
> >     -> Problem_ID numeric(7,0) NOT NULL AUTO_INCREMENT,
> >     -> Request_Date date not null,
> >     -> Completed_Date date,
> >     -> Description text not null,
> >     -> Status_ID numeric(7,0) NOT NULL,
> >     -> primary key (Subscriber_ID, Problem_ID)
> >     -> );
> > ERROR 1075: Incorrect table definition; There can only be one auto column and
> it
> >  must be defined as a key
> 
> There must be a seperate key for the auto column Problem_ID, so add
> 
> unique (Problem_ID)
> 
> >
> > This works fine if I remove the auto_increment from the Problem_ID column.
> 
> Bye,
> 
>         Benjamin.

Hi Benjamin

1) The Key doesn't have to be UNIQUE it also can be a 'normal' KEY.
2) If you change the order in your PRIMARY KEY definition it will work:
PRIMARY KEY (Problem_ID, Subscriber_ID)

So if you don't need this specific order for some query, then just use the 2) part.

Tschau
Christian

Thread
pri key auto_increment problemGeocrawler.com10 Aug
  • Re: pri key auto_increment problemBenjamin Pflugmann11 Aug
  • Re: pri key auto_increment problemChristian Mack11 Aug