PostgreSQL 8.3 上的 Bigint

发布于 2024-09-27 17:20:45 字数 300 浏览 0 评论 0 原文

我有一个用户表,其主键 uid 数据类型为 bigint。

我不明白为什么在尝试添加 uid = 100000349053153 的用户时出现错误:“Minteger out of range”。

这应该有效(根据文档:http://www.postgresql.org/docs/8.3/static/datatype.html)

I have a users table with a primary key uid of data type bigint.

I don't understand why I get the error : "Minteger out of range" when trying to add a user with uid = 100000349053153.

This should work (according to the doc: http://www.postgresql.org/docs/8.3/static/datatype.html)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

淑女气质 2024-10-04 17:20:45

谢谢尼古拉斯和亚当。

这个问题与我对 Rails 的混乱使用有关。

我错误地认为 rake db:reset 从迁移文件重新创建数据库。
我有正确的迁移文件,但 rake db:reset 使用了 schema.rb 提供的错误信息

如果您想存储 Facebook ID,请使用(在您的迁移中):

t.integer :uid, :limit => 8

您还可以添加索引:

add_index :users, :uid, :unique => true

如果您想重新创建您的Rails 数据库从头开始使用:

rake db:drop
rake db:create
rake db:migrate

Thanks Nicholas and Adam.

The problem was tied to my confused use of Rails.

I was wrong to think that rake db:reset recreates the database from the migration files.
I had the correct migration files but rake db:reset was using the wrong information provided by schema.rb

If you want to store Facebook ID, use (inside your migrations):

t.integer :uid, :limit => 8

You can also add an index:

add_index :users, :uid, :unique => true

And if you want to recreate your Rails database from scratch use:

rake db:drop
rake db:create
rake db:migrate
相权↑美人 2024-10-04 17:20:45

FWIW 以下对我来说效果很好:

CREATE TABLE bigintexample
(
  id bigint,
  CONSTRAINT pk_bigintexample_id PRIMARY KEY (id)
);

INSERT INTO bigintexample (id) VALUES (100000349053153);

FWIW the following works just fine for me:

CREATE TABLE bigintexample
(
  id bigint,
  CONSTRAINT pk_bigintexample_id PRIMARY KEY (id)
);

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