gpt4 book ai didi

mysql - 错误 1062 (23000) : Duplicate entry '2147483647' for key 'PRIMARY'

转载 作者:行者123 更新时间:2023-11-29 04:22:19 24 4
gpt4 key购买 nike

我有一张 table :

CREATE TABLE passenger_details
(
bank_card INT(20) NOT NULL AUTO_INCREMENT,
email VARCHAR(20),
mobile INT(15) NOT NULL,
p_id INT NOT NULL,
PRIMARY KEY (bank_card),
FOREIGN KEY (p_id) REFERENCES passenger(p_id)
);

INSERT INTO passenger_details
VALUES (0123012301230123,'blah_@hotmail.com',0872863492,1234);
select*from passenger_details;
+------------+--------------------+-----------+------+
| bank_card | email | mobile | p_id |
+------------+--------------------+-----------+------+
| 2147483647 | blah_@hotmail.com | 872863492 | 1234 |
+------------+--------------------+-----------+------+
1 row in set (0.00 sec)

正如我们所见,之前的值,只是在表中出错了。应该是 16 个数字而不是只有 10 个,实际上是不同的数字。
当我尝试插入一个新值时:

INSERT INTO passenger_details 
VALUES (1234258431681842,'blah@icloud.com',0895764829,123548);

我收到这个错误:

ERROR 1062 (23000): Duplicate entry '2147483647' for key 'PRIMARY'

如果 bank_card 是 AUTO_INCREMENT 为什么会出错?我应该把 PK 换到另一个地方吗?

最佳答案

INT 有一个 maximum signed value of 2147483647 .任何大于该值的数字都将被截断为该值。您需要做的是将该列更改为一个 varchar(20) ,它将保存最多 20 个字符的字符串,因为银行卡号是字符串而不是实际数字(您不使用这)。您还应该删除 AUTO_INCREMENT,因为这不是您要递增的值。

关于mysql - 错误 1062 (23000) : Duplicate entry '2147483647' for key 'PRIMARY' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20442140/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com