我有下表:
CREATE TABLE `cat_matches` (
`from_cat` int(11) NOT NULL,
`to_cat` int(11) NOT NULL,
`tag` char(10) DEFAULT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `cat_matches_ibfk_1` (`from_cat`),
KEY `cat_matches_ibfk_2` (`to_cat`),
CONSTRAINT `cat_matches_ibfk_1` FOREIGN KEY (`from_cat`) REFERENCES `category` (`id`),
CONSTRAINT `cat_matches_ibfk_2` FOREIGN KEY (`to_cat`) REFERENCES `category` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2519 DEFAULT CHARSET=latin1
在很多其他主题中,人们回答“在Workbench中,表必须有一个可编辑的PK”。但正如您所看到的,此表包含一个名为id的列,它是PK,但仍然不可编辑。为什么呢?