Enforcing serial uniqueness?

Поиск
Список
Период
Сортировка
От Steven Brown
Тема Enforcing serial uniqueness?
Дата
Msg-id dvqv2b$3e0$1@sea.gmane.org
обсуждение исходный текст
Ответы Re: Enforcing serial uniqueness?
Список pgsql-general
I want to allow access to a table's rows without allowing that table to
be damaged.  A problem I have is with my serial primary key 'id' field.
  Although I can block its UPDATE, if users INSERT with an explicit 'id'
higher than the sequence, future INSERTs will fail due to the values
colliding.  Ditto if users modify the sequence (setval) to be lower than
existing 'id' fields.  This is rather bad, as it prevents
anyone/anything from INSERTing until fixed by manual intervention.

This is probably a common question - how do I fix the above problems?

I'd be happy with them not being able to explicitly set 'id' at all as
I'd rather they also not be able to cause the reuse of a deleted id, but
the 'select nextval, insert, use id' paradigm seems to require it.
Also, if I could block 'setval', that would seem to prevent the latter
problem, but it doesn't seem possible to block 'setval' while still
allowing 'nextval'.

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

Предыдущее
От: "Qingqing Zhou"
Дата:
Сообщение: Re: invalid page header
Следующее
От: "Andrus"
Дата:
Сообщение: Re: How to release locks