Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
634 views
in Technique[技术] by (71.8m points)

mysql - Error 1062 - Duplicate entry '127' for key 'PRIMARY' - can't find the reason

I'm getting this error:

#1062 - Duplicate entry '127' for key 'PRIMARY'

and can't find the reason.

The query :

INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('00');
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('01'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('02'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('03'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('04'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('05'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('06'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('07'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('08'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('09'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('0A'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('0B'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('0C'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('0D'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('0E'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('0F'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('10'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('11'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('12'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('13'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('14'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('15'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('16'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('17'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('18'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('19'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('1A'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('1B'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('1C'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('1D'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('1E'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('1F'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('20'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('21'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('22'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('23'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('24'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('25'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('26'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('27'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('28'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('29'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('2A'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('2B'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('2C'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('2D'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('2E'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('2F'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('30'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('31'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('32'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('33'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('34'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('35'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('36'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('37'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('38'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('39'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('3A'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('3B'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('3C'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('3D'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('3E'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('3F'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('40'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('41'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('42'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('43'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('44'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('45'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('46'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('47'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('48'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('49'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('4A'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('4B'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('4C'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('4D'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('4E'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('4F'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('50'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('51'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('52'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('53'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('54'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('55'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('56'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('57'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('58'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('59'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('5A'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('5B'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('5C'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('5D'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('5E'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('5F'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('60'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('61'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('62'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('63'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('64'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('65'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('66'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('67'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('68'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('69'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('6A'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('6B'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('6C'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('6D'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('6E'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('6F'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('70'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('71'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('72'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('73'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('74'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('75'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('76'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('77'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('78'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('79'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('7A'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('7B'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('7C'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('7D'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('7E'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('7F'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('80'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('81'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('82'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('83'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('84'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('85'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('86'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('87'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('88'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('89'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('8A'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('8B'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('8C'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('8D'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('8E'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('8F'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('90'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('91'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('92'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('93'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('94'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('95'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('96'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('97'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('98'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('99'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('9A'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('9B'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('9C'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('9D'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('9E'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('9F'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('A0'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('A1'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('A2'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('A3'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('A4'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('A5'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('A6'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('A7'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('A8'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('A9'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('AA'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('AB'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('AC'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('AD'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('AE'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('AF'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('B0'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('B1'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('B2'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('B3'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('B4'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('B5'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('B6'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('B7'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('B8'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('B9'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('BA'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('BB'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('BC'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('BD'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('BE'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('BF'); 
INSERT INTO `portautomadb`.`tag` (`codigo`) VALUES ('C0'); 
INSERT INTO

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

signed TINYINT can contain numbers frmo -128 to 127. You most likely already have 127 rows in your table, so your primary key column can't contain more. Change your datatype do SMALLINT UNSIGNED (0-65535) MEDIUMINT UNSIGNED (0-16777215) or just INT UNSIGNED (0-4294967295) - that lasst one should be more than enough


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...