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