>
Thanks for the reply. For the time begin I've solved this by copying every
table in the database to a backup table without any constraints, recreating
the tables and copying the data back in. I have to be a bit careful with
doing it all in the right order, although I think I can solve this by doing
everything in a transaction as the constraints are only checked at the end of
transaction?
> >
> > So I guess my question really boils down to: is it possible to write a
> > function that drops a foreign key trigger or re-instates it? This should
> > really be ALTER TABLE table ALTER COLUMN column (DROP|CREATE)
> > CONSTRAINT.... or something along those lines.
>
> There's still something missing in ALTER TABLE. DROP
> CONSTRAINT is one of them, but since your sequencs with
> renaming the old etc. is the safest possibility anyway, it's
> not that high priority.
OK, I'm definitely not being very bright here, but i cannot get my system to
accept the alter column commands. An example on the man pages ,ay help a lot
here! I tried
test=# create table t (i int4);
CREATE
test=# create table t1 (k int4);
CREATE
test=# alter table t1 alter column k add constraint references t(i);
ERROR: parser: parse error at or near "add"
test=# alter table t1 alter column k constraint references t(i);
ERROR: parser: parse error at or near "constraint"
test=# alter table t1 alter k constraint references t(i);
ERROR: parser: parse error at or near "constraint"
test=# alter table t1 alter column k create constraint references t(i);
ERROR: parser: parse error at or near "create"
So what am I doing wrong?
Thanks,
Adriaan