On Wed, Apr 28, 2004 at 10:13:14 +0200,
Edoardo Ceccarelli <eddy@axa.it> wrote:
> do you mean that, declaring an index serial, I'd never have to deal with
> incrementing its primary key? good to know!
That isn't what is happening. Serial is a special type. It is int plus
a default rule linked to a sequence. No index is created by default
for the serial type. Declaring a column as a primary key will however
create a unique index on that column.
Also note that you should only assume that the serial values are unique.
(This assumes that you don't use setval and that you don't roll a sequence
over.) Within a single session you can assume the sequence values will
be monotonicly increasing. The values that end up in your table can have
gaps. Typically this happens when a transaction rolls back after obtaining
a new value from a sequence. It can also happen if you grab sequence
values in larger blocks (which might be more efficient if a session normally
acquires mulitple values from a particular sequence) than the default 1.
> anyway in this particular situation I don't need such accurate
> behaviour: this table is filled up with a lot of data twice per week and
> it's used only to answer queries.
> I could drop it whenever I want :)
You really don't want to use oids.