Is it safe to use DEFAULT currval()

From: Richard Huxton <dev(at)archonet(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Is it safe to use DEFAULT currval()
Date: 2003-09-27 16:40:27
Message-ID: 200309271740.27943.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I've got a table, and I'm trying to track changes to it, but can't do it via a
primary key including a revision-number (historical reasons).

CREATE TABLE foo (
id SERIAL,
blah text,
tracking int4 DEFAULT currval('foo_id_seq')
PRIMARY KEY (id)
);

I'm actually setting the DEFAULT on tracking using ALTER TABLE after the
event.

Now - it works, but is that a design feature or just luck?

It's convenient that tracking = id of the first entry, but not vital, so I can
always use a separate sequence if needs be.

--
Richard Huxton
Archonet Ltd

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2003-09-27 16:57:52 Re: PostgreSQL Delphi
Previous Message Tom Lane 2003-09-27 16:38:40 Re: Schema backup - SOLVED