Re: How to enforce the use of the sequence for serial columns

Поиск
Список
Период
Сортировка
От Ben K.
Тема Re: How to enforce the use of the sequence for serial columns
Дата
Msg-id Pine.GSO.4.64.0612140543270.20249@coe.tamu.edu
обсуждение исходный текст
Ответы Re: How to enforce the use of the sequence for serial columns
Список pgsql-admin

> create table mytable (myid serial primary key constraint
mytable_myid_chk check
(myid = currval('mytable_myid_seq'), mydata varchar(255), ...);


I'd like to clarify that this will not be a full solution, since it will
not allow update of the table unless nextval has been used in the same
sequence already.

There seems to be a hack in case of oracle that allows using currval
without nextval, but it's a hack and I don't know if there's an equivalent
in postgresql (http://rootshell.be/~yong321/computer/sequence.txt).
(Oracle seems to have "disable" option when adding check constraint by
alter table, but the context seem a bit different from ours so may not be
useful in our case, at any rate.)




Regards

Ben K.
Developer
http://benix.tamu.edu




---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

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

Предыдущее
От: "Eduardo J. Ortega"
Дата:
Сообщение: Re: Backup
Следующее
От: Jerry Sievers
Дата:
Сообщение: Re: How to enforce the use of the sequence for serial columns