MySQL Forums
Forum List  »  Newbie

Re: table with multiple primary key
Posted by: Peter Brawley
Date: September 02, 2014 10:10AM

>> since auto_increment is allowed only in a PK
> False. (I have to admit that I thought that was true for many years.)

drop table if exists t;
create table t(i int auto_increment);
[ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key

However MySQL is smarter than I thought, and Rick's suggestion works:

alter table test drop primary key, add primary key(date), add index(id);

Options: ReplyQuote


Subject
Written By
Posted
September 01, 2014 11:03PM
September 02, 2014 12:27AM
Re: table with multiple primary key
September 02, 2014 10:10AM
September 02, 2014 07:14PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.