id在Postgresql中可以获取多大 [英] How large can an id get in postgresql
本文介绍了id在Postgresql中可以获取多大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用PostgreSQL,想知道有多大
I am using postgresql, and was wondering how large
id INTEGER PRIMARY KEY
可以与
id SERIAL PRIMARY KEY
在Java中, int
为4个位元组(32位元),因此最多可达2,147,483,647。在PostgreSQL中是这种情况吗?如果是这样,是否意味着我不能超过2,147,483,647行?
In java an int
is 4 bytes (32 bits) so it can get up to 2,147,483,647. Is this the case in postgresql? If so does that mean I cannot go past 2,147,483,647 rows?
推荐答案
以下是PostgreSQL的方便图表:
Here is a handy chart for 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
您的评估是正确的,如果使用的数据类型不足,您将用不完唯一ID
Your assessment is right, you'd run out of unique ID's if you used a data type that was insufficient.
这篇关于id在Postgresql中可以获取多大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文