我正在使用 postgresql,想知道有多大
id INTEGER PRIMARY KEY
可以比较
id SERIAL PRIMARY KEY
在 java 中,int
是 4 个字节(32 位),因此它最多可以达到 2,147,483,647。在 postgresql 中是这种情况吗?如果是这样,是否意味着我不能超过 2,147,483,647 行?
最佳答案
这是 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
smallserial 2 bytes small autoincrementing integer 1 to 32767
serial 4 bytes autoincrementing integer 1 to 2147483647
bigserial 8 bytes large autoincrementing integer 1 to 9223372036854775807
您的评估是正确的,如果您使用的数据类型不充分,您将用完唯一 ID。
关于postgresql - postgresql 中的 id 有多大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17755447/