Reputation: 18535
Here is the sql, however, there is an error says "*#1061 - Duplicate key name 'unique_id'* ", what is the problem.
create table `users`(
uid int(11) auto_increment,
unique_id varchar(23) not null unique,
name varchar(50) not null,
email varchar(100) not null unique,
encrypted_password varchar(80) not null,
salt varchar(10) not null,
created_at datetime,
updated_at datetime null,
PRIMARY KEY (`unique_id`),
UNIQUE KEY `uid` (`uid`),
UNIQUE KEY `unique_id` (`unique_id`),
UNIQUE KEY `email` (`email`)
)ENGINE=InnoDB AUTO_INCREMENT=877888 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Upvotes: 3
Views: 12520
Reputation: 263703
remove this line
UNIQUE KEY `unique_id` (`unique_id`),
since unique_id
is already Primary Key
. and Primary Keys
are unique.
full CREATE TABLE
statement
create table `users`
(
uid int(11) auto_increment,
unique_id varchar(23) not null,
name varchar(50) not null,
email varchar(100) not null unique, -- specified here
encrypted_password varchar(80) not null,
salt varchar(10) not null,
created_at datetime,
updated_at datetime null,
PRIMARY KEY (`unique_id`),
UNIQUE KEY `uid` (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=877888
DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Upvotes: 13