Re: SQL CONSTRAINTS - Constraining time values from two

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: "Maher, Christopher W" <christopher(dot)w(dot)maher(at)intel(dot)com>
Cc: "'pgsql-sql(at)postgresql(dot)org'" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: SQL CONSTRAINTS - Constraining time values from two
Date: 2001-10-05 21:12:19
Message-ID: Pine.LNX.4.30.0110052143030.654-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Maher, Christopher W writes:

> I was looking for a solution on how to write a constraint into a ' create
> table ' expression that would ensure that one ' TIME ' attribute value
> called arrival_time (declared as TIME) is allways constrained to have a
> value that ensures it is allways after another attribute value called
> departure_time (declared as TIME).

create table test (
arrival_time time,
departure_time time,
check (arrival_time < departure_time)
);

insert into test values ('12:00', '14:30');
INSERT 20651 1

insert into test values ('12:00', '9:45');
ERROR: ExecAppend: rejected due to CHECK constraint $1

--
Peter Eisentraut peter_e(at)gmx(dot)net http://funkturm.homeip.net/~peter

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Oleg Lebedev 2001-10-05 22:28:26 Quotes and spaces
Previous Message Alex Pilosov 2001-10-05 21:01:33 Re: temporary views