From: | Sven Willenberger <sven(at)dmv(dot)com> |
---|---|
To: | David Fetter <david(at)fetter(dot)org> |
Cc: | Matthew Terenzio <matt(at)jobsforge(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: sequence advances on failed insert |
Date: | 2005-04-08 03:27:41 |
Message-ID: | 4255FA2D.3030504@dmv.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
David Fetter presumably uttered the following on 04/07/05 20:16:
> On Thu, Apr 07, 2005 at 07:59:52PM -0400, Matthew Terenzio wrote:
>
>>I'm noticing that a sequence is advancing even if the insertion
>>fails. Is this weird or expected?
>
>
> It's expected. Sequences are guaranteed to generate unique IDs.
> These happen to be an increasing sequence of integers, but there is no
> attempt to make this a gap-free sequence, and your apps should not
> depend on the actual value of said ID.
I assume by "not depend on the actual value" that one should not assume
that the next value will be one increment higher than the current
highest value in the table; because it is guaranteed to be unique, I
would think it to be an excellent way to assign a customer id, for
example, which can then be referenced (foreign key, etc) by other tables
after a new record is added. Unless there is some other reason one
should not use a sequence value as any type of identifier?
Sven
From | Date | Subject | |
---|---|---|---|
Next Message | David Fetter | 2005-04-08 03:33:50 | Re: sequence advances on failed insert |
Previous Message | Steve - DND | 2005-04-08 02:52:01 | Can't install plpython on Windows 8.0 |