sequence newbie question

From: "Kevin B(dot)" <db(at)ke5in(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: sequence newbie question
Date: 2004-11-30 15:57:23
Message-ID: 33221.67.87.27.161.1101830243.squirrel@www.ke5in.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

I'm coming over from the MS sql server world and I've been reading up on
sequences. I have a question:

I see that you can create an implicit sequence like this:
CREATE TABLE test (field varchar(5), id serial NOT NULL, PRIMARY KEY (id));

And I've read that you can replace the Microsoft @@Identity by using this:
select last_value from test_id_seq;

But what if somebody else inserts a row after your insert but before your
select? Will you end up with their ID or is the "last_value" somehow
associated with the connection?

Thanks,
Kevin

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2004-11-30 16:04:00 Re: problematic upgrade
Previous Message Sean Davis 2004-11-30 15:50:02 Re: views with parameters