List:General Discussion« Previous MessageNext Message »
From:indrek siitan Date:March 30 2000 10:29pm
Subject:RE: Auto_Increment and Primary key
View as plain text  
Hi,

> I am trying to set up a table which has an auto_incrementing ID
> and a unique username. I set up the username to be the primary
> key (as it needs to be unique) and the ID to be auto_Increment. 
> This came up with an error and said that the index column must be
> the auto_increment.

the username does not have to be primary key to be required to be
unique. you can create the table as following:

CREATE TABLE users (
  id int not null auto_increment primary key,
  username varchar(10) not null,

  /.. the rest of the fields ../

  unique (username)
);


Rgds,
  Tfr

  --==< tfr@stripped >==< http://tfr.cafe.ee/ >==< +1-504-4467425 >==-- 
Thread
Auto_Increment and Primary keyJonathan Howells30 Mar
  • RE: Auto_Increment and Primary keyChris Johnson30 Mar
  • RE: Auto_Increment and Primary keyindrek siitan31 Mar