Is it safe to use DEFAULT currval()

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Is it safe to use DEFAULT currval()
Дата
Msg-id 200309271740.27943.dev@archonet.com
обсуждение исходный текст
Ответы Re: Is it safe to use DEFAULT currval()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Schema backup - SOLVED
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: PostgreSQL Delphi