guaranteeing that a sequence never skips - Mailing list pgsql-general

From David Garamond
Subject guaranteeing that a sequence never skips
Date
Msg-id 41601392.5000800@zara.6.isreserved.com
Whole thread Raw
Responses Re: guaranteeing that a sequence never skips
List pgsql-general
Am I correct to assume that SERIAL does not guarantee that a sequence
won't skip (e.g. one successful INSERT gets 32 and the next might be 34)?

Sometimes a business requirement is that a serial sequence never skips,
e.g. when generating invoice/ticket/formal letter numbers. Would an
INSERT INTO t (id, ...) VALUES (SELECT MAX(col)+1 FROM t, ...) suffice,
or must I install a trigger too to do additional checking?

--
dave


pgsql-general by date:

Previous
From: Mike Rylander
Date:
Subject: Re: Query problem...
Next
From: Alvaro Herrera
Date:
Subject: Re: sequence rename?