Re: Insert in table with UNIQUE index

Поиск
Список
Период
Сортировка
От bricklen
Тема Re: Insert in table with UNIQUE index
Дата
Msg-id CAGrpgQ-Fk7OHjm7E+kcm6QYH5Gz4puqWHDW6Uuj9uUw9-adegg@mail.gmail.com
обсуждение исходный текст
Ответ на Insert in table with UNIQUE index  (Artem Tomyuk <admin@leboutique.com>)
Список pgsql-admin

On Wed, Jan 27, 2016 at 5:30 AM, Artem Tomyuk <admin@leboutique.com> wrote:
I have a table with unique index with 2 exactly the same rows.
How it can be possible?


CREATE TABLE _inforgchngr6716_test
(
  _nodetref bytea NOT NULL,
  _noderref bytea NOT NULL,
  _messageno numeric(10,0)
)

CREATE UNIQUE INDEX _inforg6716_bynodemsg_rn_test
  ON _inforgchngr6716_test
  USING btree
  (_nodetref, _noderref, _messageno);

In the duplicated entries, are any of the "_messageno" values NULL? If so, that would explain it. NULL is not bound by the constraint, you have a few options: make it NOT NULL, COALESCE() it to a known value, or create a couple partial indexes to enforce the uniqueness.

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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Insert in table with UNIQUE index
Следующее
От: Jeff Frost
Дата:
Сообщение: Re: 9.5 repo question