PostgreSql在整数字段中插入小数时,整数超出范围错误

时间:2011-09-29 21:22:16

标签: django postgresql

我在postgres中遇到“整数超出范围”错误,但插入的数字都不是“大”。他们远远不到一百万。 查询是通过Django ORM生成的,非常标准。 知道我在这里缺少什么吗? 谢谢!

# INSERT INTO "index_index" ("word_id", "ad_id", "field", "position", "created_at") VALUES (98036, 703906, E'y.x', 0, E'2011-09-29 22:02:40.252332') RETURNING "index_index"."id";
ERROR:  integer out of range

# \d index_index;

Table "public.index_index"
   Column   |           Type           |                        Modifiers                         
------------+--------------------------+----------------------------------------------------------
 id         | integer                  | not null default nextval('index_index_id_seq'::regclass)
 word_id    | integer                  | not null
 ad_id      | integer                  | not null
 field      | character varying(50)    | not null
 position   | integer                  | not null
 created_at | timestamp with time zone | not null
Indexes:
    "index_index_pkey" PRIMARY KEY, btree (id)
    "index_index_ad_id" btree (ad_id)
    "index_index_word_id" btree (word_id)
Foreign-key constraints:
    "index_index_ad_id_fkey" FOREIGN KEY (ad_id) REFERENCES campaigns_ad(id) DEFERRABLE INITIALLY DEFERRED
    "index_index_word_id_fkey" FOREIGN KEY (word_id) REFERENCES index_word(id) DEFERRABLE INITIALLY DEFERRED

1 个答案:

答案 0 :(得分:8)

可能序列已超过最大值。整数的值(2147483647)。由于序列基于bigint,因此这是可能的。

您可以使用SELECT nextval('index_index_id_seq')

进行测试