* Ben <[EMAIL PROTECTED]> [2004-10-06 08:23:11 -0700]: > If I have have the table: > > create table foo > ( > a int references bar(id), > b int references baz(id) > ) > > ... how do I make sure one and only one of the columns a and b are > non-null? Is it even reasonable?
ALTER TABLE foo ADD CONSTRAINT must_have_a_or_b CHECK (a::int IS NULL AND b::int IS NOT NULL OR a::int IS NOT NULL AND b::int IS NULL); -- Steven Klassen - Lead Programmer Command Prompt, Inc. - http://www.commandprompt.com/ PostgreSQL Replication & Support Services, (503) 667-4564 ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster