id在postgresql中有多大

abd*_*003 15 postgresql integer primary-key

我正在使用postgresql,并想知道有多大

id INTEGER PRIMARY KEY
Run Code Online (Sandbox Code Playgroud)

可以得到比较

id SERIAL PRIMARY KEY
Run Code Online (Sandbox Code Playgroud)

在java中,a int是4个字节(32位),因此它可以达到2,147,483,647.在postgresql中是这种情况吗?如果是这样意味着我不能超过2,147,483,647行?

Har*_* CO 38

这是PostgreSQL的一个方便的图表:

Name        Storage Size    Description                       Range
smallint    2 bytes         small-range integer               -32768 to +32767
integer     4 bytes         usual choice for integer          -2147483648 to +2147483647
bigint      8 bytes         large-range integer               -9223372036854775808 to 9223372036854775807
serial      4 bytes         autoincrementing integer          1 to 2147483647
bigserial   8 bytes         large autoincrementing integer    1 to 9223372036854775807
Run Code Online (Sandbox Code Playgroud)

资源

您的评估是正确的,如果您使用的数据类型不足,则您将使用唯一ID.

  • ..但如果你使用'bigint`(或`bigserial`,这是同一件事)[你真的,真的不会用完](http://stackoverflow.com/questions/13132939/what-happens-当-I-排气-A-BIGINT生成的密钥知识对把手它/ 13133035#13133035). (3认同)