Reputation:
I'm new to the postgresql and i want to know how many byte unique integers do OIDs in postgresql have? I am using postgresql version 9.3.
Upvotes: 1
Views: 411
Reputation: 6733
OIDs in PostgreSQL have 4 byte unique integers. That is each row in PostgreSQL would be assigned a unique OID. Though the concept of unique OID exists in PostgreSQL for each row after sufficient number of rows overflowing occurs and the OID value gets repeated from this stage.
Upvotes: 1
Reputation: 324541
OID
is a 32-bit (4-byte) unsigned integer. So it has the range 0 - 4294967295.
regress=> SELECT OID '4294967295';
oid
------------
4294967295
(1 row)
regress=> SELECT OID '4294967296';
ERROR: value "4294967296" is out of range for type oid
LINE 1: SELECT OID '4294967296';
^
You should not use the oid
data type. It is not a data type intended for user consumption. It's a system type for system use. Forget it exists. The only acceptable user uses for oids
are to refer to objects in pg_largeobject
, and there you should instead use the lo
type provided by the lo
extension instead.
Do not create tables WITH OIDS
. That's a legacy feature that's only retained for backward compatibility and for use in system tables. Again, forget it exists. If you want a row identifier, use serial
, or if you're worried about running out of unique values, use bigserial
.
Upvotes: 6