Postgres:整数超出范围 [英] Postgres: integer out of range
问题描述
我正在运行以下查询:
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
推荐答案
考虑更改您的表以使用更大的整数(有关详细信息,请参见此处:http://www.postgresql.org/docs/9.1/static/datatype-numeric.html).
Consider altering your table to use a bigger integer (see here for details: http://www.postgresql.org/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:整数超出范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!