I have this table:
CREATE TABLE `event_schedule_tag` (
`event_schedule_id` bigint(20) NOT NULL,
`tag_id` bigint(20) NOT NULL,
KEY `event_schedule_id` (`event_schedule_id`),
KEY `tag_id` (`tag_id`),
CONSTRAINT `event_schedule_tag_ibfk_1` FOREIGN KEY (`event_schedule_id`) REFERENCES `event_schedule` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci
And I want to add primary key over the two columns. But when I execute
alter table event_schedule_tag add primary key(event_schedule_id, tag_id);
I get:
ERROR 1062 (23000): Duplicate entry '1130915-260' for key 'PRIMARY'
and when I execute
alter table event_schedule_tag drop primary key;
I get:
ERROR 1091 (42000): Can't DROP 'PRIMARY'; check that column/key exists
What is the way out?
EDIT: I got the error message wrong. I though it says "primary key already exists" while the meaning is: "there are duplicates in the table -> can't create primary key" which makes much more sense now. I deleted duplicates and created primary key with no problem. Thanks!