Re: PRIMARY KEY on a *group* of columns imply that each column is NOT NULL?

Поиск
Список
Период
Сортировка
От Guy Rouillier
Тема Re: PRIMARY KEY on a *group* of columns imply that each column is NOT NULL?
Дата
Msg-id CC1CF380F4D70844B01D45982E671B239E87C4@mtxexch01.add0.masergy.com
обсуждение исходный текст
Ответ на PRIMARY KEY on a *group* of columns imply that each column is NOT NULL?  (Stephane Bortzmeyer <bortzmeyer@nic.fr>)
Ответы Re: PRIMARY KEY on a *group* of columns imply that each column is NOT  (Stephane Bortzmeyer <bortzmeyer@nic.fr>)
Список pgsql-general
Stephane Bortzmeyer wrote:
> If I define a primary key:
>
>        name TEXT NOT NULL,
>        address INET,
>        PRIMARY KEY(name, address)
>
> the definition (seen by \d) becomes:
>
>  name          | text                        | not null
>  address       | inet                        | not null
>
> "address" is now not null, which I do not want. It seems unnecessary:
> I just want the tuple (name, address) to be unique, which seems
> possible even if some 'address' values are NULL.
>
> It does not appear to be documented in
>
http://www.postgresql.org/docs/7.4/interactive/ddl-constraints.html#AEN1
975.
> Is there a workaround?

Per the SQL Commands Reference, under CREATE TABLE:

"The primary key constraint specifies that a column or columns of a
table may contain only unique (non-duplicate), nonnull values.
Technically, PRIMARY KEY is merely a combination of UNIQUE and NOT NULL"

Primary key columns cannot contain null values.

--
Guy Rouillier


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

Предыдущее
От: Stephane Bortzmeyer
Дата:
Сообщение: PRIMARY KEY on a *group* of columns imply that each column is NOT NULL?
Следующее
От: "Mohan, Ross"
Дата:
Сообщение: Re: UltraSPARC versus AMD - Slowaris