Re: unique constraint on 2 columns

Поиск
Список
Период
Сортировка
От Vladimir Zelinski
Тема Re: unique constraint on 2 columns
Дата
Msg-id 606523.60764.qm@web52708.mail.re2.yahoo.com
обсуждение исходный текст
Ответ на Re: unique constraint on 2 columns  (Jorge Godoy <jgodoy@gmail.com>)
Ответы Re: unique constraint on 2 columns
Список pgsql-general
This looks like more table design problem than
database limitation.
The one column should accommodate values from both
columns with unique index built on this column. Your
requirements tell me that these values are the same
nature and should be placed in the same column. To
distinguish between them use another column to put an
attribute.


--- Jorge Godoy <jgodoy@gmail.com> wrote:

> Jonathan Vanasco <postgres@2xlp.com> writes:
>
> > I need a certain unique constraint in pg that i
> can't figure out.
> >
> > Given:
> >
> >     create table test_a (
> >         id serial ,
> >         name_1 varchar(32) ,
> >         name_2 varchar(32)
> >     );
> >
> > I need name_1 and name_2 to both be unique so
> that:
> >     name_1 never appears in name_1 or name_2
> >     name_2 never appears in name_2 or name_1
> >
> >
> > a standard 2 column unique index / constraint will
> not accomplish this.
>
> But a trigger will...
>
> --
> Jorge Godoy      <jgodoy@gmail.com>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: cant get pg_dump/pg_restore to behave
Следующее
От: Tom Lane
Дата:
Сообщение: Re: large table problem