Re: not null across multiple columns

From: "George Pavlov" <gpavlov(at)mynewplace(dot)com>
To: "Matthew Terenzio" <matt(at)jobsforge(dot)com>, "PostgreSQL general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: not null across multiple columns
Date: 2006-11-03 00:26:20
Message-ID: 8C5B026B51B6854CBE88121DBF097A865925E9@ehost010-33.exch010.intermedia.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

several ways to do it, here's one:

check (coalesce(a,b,c) not null)

if you want one or the other to be present, but not both see this
thread:

http://archives.postgresql.org/pgsql-general/2006-09/msg00207.php

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of
> Matthew Terenzio
> Sent: Thursday, November 02, 2006 4:11 PM
> To: PostgreSQL general
> Subject: [GENERAL] not null across multiple columns
>
>
> here is an interesting question (to me)
>
> 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?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Reece Hart 2006-11-03 00:29:16 Re: not null across multiple columns
Previous Message Matthew Terenzio 2006-11-03 00:10:41 not null across multiple columns