How large can an id get in postgresql

后端 未结 2 2036
梦毁少年i
梦毁少年i 2021-01-01 16:49

I am using postgresql, and was wondering how large

id INTEGER PRIMARY KEY

can get compared to

id SERIAL PRIMARY KEY
         


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-01 17:16

    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
    

    Source

    Your assessment is right, you'd run out of unique ID's if you used a data type that was insufficient.

提交回复
热议问题