From: | Andreas Joseph Krogh <andreak(at)officenet(dot)no> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Conditional NOT NULL constraint |
Date: | 2007-02-28 10:30:47 |
Message-ID: | 200702281130.47396.andreak@officenet.no |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi all!
Is there a simple way to add a "NOT NULL constraint" to a column without using
a trigger if another column is not null?
Something like this:
CREATE TABLE activity(
id SERIAL primary key,
name varchar not null,
created timestamp not null default now(),
modified timestamp,
created_by integer not null,
modified_by integer
);
alter table activity alter column modified_by set not null where modified is
not null;
I want a constraint which says: "modified_by not null if modified is not
null".
I know I could use a trigger for this, but I'm curious if there is a way to do
this with an index.
--
Andreas Joseph Krogh <andreak(at)officenet(dot)no>
Senior Software Developer / Manager
gpg public_key: http://dev.officenet.no/~andreak/public_key.asc
------------------------+---------------------------------------------+
OfficeNet AS | The most difficult thing in the world is to |
Karenslyst Allé 11 | know how to do a thing and to watch |
PO. Box 529 Skøyen | somebody else doing it wrong, without |
0214 Oslo | comment. |
NORWAY | |
Mobile: +47 909 56 963 | |
------------------------+---------------------------------------------+
From | Date | Subject | |
---|---|---|---|
Next Message | calendarw | 2007-02-28 10:33:04 | How to union table without union statement? |
Previous Message | S.F. Lee | 2007-02-28 01:56:39 | unsubscribe |