Postgres:整数超出范围

编程入门 行业动态 更新时间:2024-10-25 00:36:33
本文介绍了Postgres:整数超出范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在运行以下查询:

WITH match_team_vals(match_id, team_id, is_radiant) AS ( VALUES (2281450916, 2783913, true), (2281450916, 2538753, false) ) INSERT INTO dota_match_team(match_id, team_id, is_radiant) SELECT match_id, team_id, is_radiant FROM match_team_vals RETURNING id AS lineup_id

在这张桌子上:

CREATE TABLE dota_match_team ( id serial NOT NULL, match_id integer NOT NULL, team_id integer, is_radiant boolean NOT NULL, CONSTRAINT dota_match_teams_pkey PRIMARY KEY (id) )

我得到的错误信息是

ERROR: integer out of range SQL state: 22003

我尝试将 match_id 和 team_id 转换为 bigint.也在网上看我看到人们有这个问题,串行达到整数的上限.似乎并非如此:

I've tried casting the match_id and team_id to bigint. Also looking online I see that people have this issue with the serial hitting the upper limit of integers. This doesn't seem to be the case:

SELECT nextval('dota_match_team_id_seq') returns 31

推荐答案

考虑更改您的表以使用更大的整数(有关详细信息,请参见此处:www.postgresql/docs/9.1/static/datatype-numeric.html).

Consider altering your table to use a bigger integer (see here for details: www.postgresql/docs/9.1/static/datatype-numeric.html).

我认为问题在于,您的 match_id 和 team_id 属于 integer 类型,而您尝试插入值 2281450916,但整数的最大值为 2147483647

I think the problem is, that your match_id and team_id are of type integer and you try to insert the value 2281450916, but integer's maximum is 2147483647

更多推荐

Postgres:整数超出范围

本文发布于:2023-10-16 12:16:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1497527.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:整数   Postgres

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!