On Thu, 24 Aug 2000, John McKown wrote:
> The syntax that I've seen is:
>
> insert into KEY_ITEM (key_item_id,keyname) values
> (select max(key_item_id)+1,'?' FROM KEY_ITEM);
>
> Just out of curiousity, why not make key_item_id a SERIAL field? That way,
> if you don't specify a value, it gets the next value from the associated
> sequence.
I was going to ask you to explain SERIAL but the documentation makes it
fairly clear.. basically just the next value, yes? Simply setting the
field type to SERIAL seems to be the same as the MS Access 'autonumber'
field. Is this correct?
One detail that seems to have an advantage over the MAX+1 method is that
in the case of adding a new record, deleting it, then adding another new
record the ID will not be reused (correct?).
Question: What happens when transactions enter the picture? Will you get
duplicate values, or holes, or does it work just fine?
-Cedar