SQLSTATE [22003]:数值超出范围

发布于 2025-01-31 10:52:30 字数 669 浏览 5 评论 0原文

我在MySQL 5.7中有两个表格:

  • “ ID_GUIA”字段是其中之一的主要键,而另一个键则是另一个键。
  • 该字段的值是一个整数,其固定长度为11个整数字符,表示当前日期加3个自动插入整数字符(例如20220521001),
  • 这两个表都“ ID_GUIA”字段是Bigint(20)。
  • 在“ ID_GUIA”是主要键的表中,我可以插入一行而没有任何问题。
  • 在第二个表中,“ id_guia”是外键,我收到以下错误:

**

sqlstate [22003]:数值超出范围:1264超出范围值 对于第1行的“ id_guia”列(sql:插入r_productid_guiaid_productPESOcreate_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 into r_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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音栖息无 2025-02-07 10:52:30

似乎我已经溢出了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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文