SQLSTATE [22003]:数值超出范围
我在MySQL 5.7中有两个表格:
- “ ID_GUIA”字段是其中之一的主要键,而另一个键则是另一个键。
- 该字段的值是一个整数,其固定长度为11个整数字符,表示当前日期加3个自动插入整数字符(例如20220521001),
- 这两个表都“ ID_GUIA”字段是Bigint(20)。
- 在“ ID_GUIA”是主要键的表中,我可以插入一行而没有任何问题。
- 在第二个表中,“ id_guia”是外键,我收到以下错误:
**
sqlstate [22003]:数值超出范围:1264超出范围值 对于第1行的“ id_guia”列(sql:插入
r_product
(id_guia
,id_product
,PESO
,create_at_at
updated_at )valut (2022021003,1,100,2022-05-21 15:27:08,2022-05-21 15:27:08))
”
) 可以从0到18446744073709551615,因此,像20220521001这样的11个角色的整数应该毫无问题地放在那里,那我在做什么错?
I have two tables in MySQL 5.7 where:
- The field "id_guia" is primary key in one of them and a foreign key in another.
- The value of the field is an integer with fixed length of 11 integer characters that mean the current date plus three autoincrement integer characters (eg. 20220521001)
- In both of the tables the field "id_guia" is BIGINT(20).
- In the table where "id_guia" is primary key I can insert a row without any problem.
- In the second table where "id_guia" is a foreign key I receive the following error:
**
SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value
for column 'id_guia' at row 1 (SQL: insert intor_product
(id_guia
,id_product
,peso
,created_at
,updated_at
) values
(20220521003, 1, 100, 2022-05-21 15:27:08, 2022-05-21 15:27:08))"
**
Considering that bigint(20) can go from -9223372036854775807 to 9223372036854775807, and being unsigned can go from 0 to 18446744073709551615, thus an eleven character's integer like 20220521001 should fit in there without any problem, then what am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎我已经溢出了MySQL 5.7的功能。
解决此问题的解决方案是放弃MySQL 5.7并迁移到MySQL 8 dbms,我的代码可按应有的效果完美地工作。
Seems somehow that I've overflown the capabilities of Mysql 5.7.
The solution for this problem was to abandon MySQL 5.7 and migrating to a MySQL 8 DBMS where my code worked perfectly as it should.