From: Graham Ashton Date: April 14 1999 6:59am Subject: Re: How make column UNIQUE NOT NULL AUTO_INCREMENT? List-Archive: http://lists.mysql.com/mysql/1817 Message-Id: <19990414075931.B11771@wing.mirror.bt.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Wednesday 14 April, sam1600@stripped wrote: > My first question is, how in Mysql do I make a column > UNIQUE NOT NULL AUTO_INCREMENT > and at the same time add an index on it? I do this; CREATE TABLE table_name ( column_name int(255) NOT NULL AUTO_INCREMENT PRIMARY KEY ); I think you need a column to be a primary key in order for auto_increment to work. You can specify other unique relationships later. e.g. CREATE TABLE table_name ( column_name INT(255) NOT NULL AUTO_INCREMENT PRIMARY KEY second_column INT NOT NULL, third_column VARCHAR(40) NOT NULL, UNIQUE (second_column, third_column) ); > If I take the UNIQUE out of the declaration it works > but -phpMyAdmin- reports the Column and it's key as > NOT UNIQUE I think the command line mysql client says that it needs to be the primary key, not just unique. There'll be better ways of doing this, but I guess it's a start. -- Graham