>Hello,
>Ive been asking a lot of questions and I would
>like to say thanks a lot for all your responses.
>
>----------
>
>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 tried:
>
>CREATE TABLE table_name (
> column_name int(255) UNIQUE NOT NULL AUTO_INCREMENT ,
> KEY column_Inxname (column_name)
>)
>
>Mysql does not like the UNIQUE in there.
That's because UNIQUE isn't a legal part of the CREATE TABLE syntax there.
It's as simple as that. As has been pointed out in another posting, you
can use a PRIMARY KEY instead:
>CREATE TABLE table_name (
> column_name int(255) NOT NULL AUTO_INCREMENT PRIMARY KEY
>);
Note that a PRIMARY KEY is a UNIQUE index, so it may accomplish
what you want.
You could also name the UNIQUE key in a separate subclause if you
like:
CREATE TABLE table_name (column_name int(255) NOT NULL AUTO_INCREMENT,
UNIQUE (column_name)
)
--
Paul DuBois, paul@stripped
Northern League Chronicles: http://www.snake.net/nl/