Re: not null across multiple columns

Поиск
Список
Период
Сортировка
От Reece Hart
Тема Re: not null across multiple columns
Дата
Msg-id 1162513756.19432.174.camel@snafu.site
обсуждение исходный текст
Ответ на not null across multiple columns  (Matthew Terenzio <matt@jobsforge.com>)
Список pgsql-general
On Thu, 2006-11-02 at 19:10 -0500, Matthew Terenzio wrote:
> suppose you wanted to be certain that either one of two or more
> columns were present
>
> Like in a user table, either a username or an email need to be present
> to create a row.
>
> You  can't use not null because it's an either or situation.
>
> what's the best method to accomplish this sort of constraint?

See check constraints:
http://www.postgresql.org/docs/8.1/interactive/ddl-constraints.html#AEN1954

I suppose you seek something like this:
        create table people (
            name text,
            email text,
            constraint valid_name_or_email
            check (name is not null or email is not null)
        );

Cheers,
Reece

--
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0



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

Предыдущее
От: "George Pavlov"
Дата:
Сообщение: Re: not null across multiple columns
Следующее
От: louis gonzales
Дата:
Сообщение: Re: Is there anyway to...