On Mon, Jan 25, 2010 at 10:08 PM, Yong Lee wrote:
> yah, mysql only allows one auto increment field n that's used as the
> primary key in tables. I don't think it has to be the primary key as
> long as it is a unique key i think that's okay.
>
> so u should be able to do : create table (myid int
yah, mysql only allows one auto increment field n that's used as the
primary key in tables. I don't think it has to be the primary key as
long as it is a unique key i think that's okay.
so u should be able to do : create table (myid int unsigned not null
auto_increment., unique key (myid));
The requirement is that it be indexed. The index need not be a primary key.
mysql> create table t (i int not null auto_increment, index(i)) engine innodb;
Query OK, 0 rows affected (0.45 sec)
On Jan 25, 2010, at 9:39 AM, Yang Zhang wrote:
> Right, I saw the docs. I'm fine with creating an index
2010/1/25 Yang Zhang :
> Right, I saw the docs. I'm fine with creating an index on it, but the
> only way I've successfully created a table with auto_increment is by
> making it a primary key. And I still don't understand why this
> requirement is there in the first place.
Non-primary key works fo
Right, I saw the docs. I'm fine with creating an index on it, but the
only way I've successfully created a table with auto_increment is by
making it a primary key. And I still don't understand why this
requirement is there in the first place.
On Mon, Jan 25, 2010 at 10:32 AM, Tom Worster wrote:
>
it's not an innodb thing:
http://dev.mysql.com/doc/refman/5.0/en/create-table.html
"Note
"There can be only one AUTO_INCREMENT column per table, it must be indexed, and
it cannot have a DEFAULT value. An AUTO_INCREMENT column works properly only if
it contains only positive values. Inserting a