From: | missive(at)frontiernet(dot)net (Lee Harr) |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | ERROR: AlterTableAddConstraint: |
Date: | 2001-08-08 22:15:20 |
Message-ID: | 9ksdlo$1bpi$1@node21.cwnet.roc.gblx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi:
I needed to put some data in to a table using \copy
The table should look like:
CREATE TABLE AA (t timestamp default current_timestamp
CHECK (t = current_timestamp));
but in order to be able to load in the data, I had to
create the table without the constraint first. Now
I want to add in the constraint. Here is my trouble:
test=# create table a (t timestamp);
CREATE
test=# alter table a add check (t = current_timestamp);
ALTER
test=# create table b (t timestamp);
CREATE
test=# insert into b values (current_timestamp+'1 day');
INSERT 21076 1
test=# insert into a values (current_timestamp+'1 day');
ERROR: ExecAppend: rejected due to CHECK constraint $1
test=# alter table b add check (t = current_timestamp);
ERROR: AlterTableAddConstraint: rejected due to CHECK constraint <unnamed>
I tried a few things with DEFERRABLE and INITIALLY DEFERRED
but I cannot get the syntax right. Is this possible, or do I
have to hack around in the system tables to do this?
From | Date | Subject | |
---|---|---|---|
Next Message | Allan Engelhardt | 2001-08-08 22:18:32 | Re: First Saturday and Last Saturday of a month |
Previous Message | Tom Lane | 2001-08-08 21:41:30 | Re: Re: [GENERAL] Bug with ALTER TABLE |