Re: ALTER TABLE ADD CONSTRAINT - Mailing list pgsql-general

From Gregory Wood
Subject Re: ALTER TABLE ADD CONSTRAINT
Date
Msg-id 00a901c0da44$88415c30$7889ffcc@comstock.com
Whole thread Raw
In response to ALTER TABLE ADD CONSTRAINT  ("Ian Harding" <ianh@co.pierce.wa.us>)
List pgsql-general
> I am generating scripts from MSSQL Server and converting them to create
objects in PostgreSQL.  It is suprisingly easy.  However, I think I may have
hit a rock.
>
> It appears that PostgreSQL does not support listing constraints to be
added as in the following syntax:

I don't know why it won't accept that syntax, but I suspect that it might be
choking on the multiple additional constraints. Try adding each constraint
as a separate ALTER TABLE statement. This should work:

ALTER TABLE foo ADD FOREIGN KEY (fooid) REFERENCES bar (barid);
ALTER TABLE foo ADD FOREIGN KEY (footooid) REFERENCES baz (bazid);

> Is this true?  Is this something that is being considered for addition?

If you can add multiple constraints via a single ALTER TABLE according to
the SQL standard, I suspect that it will be added someday. But since you can
add them individually, I would suspect the priority would be VERY low on the
list.

> Also, I see that alter table add constraint does not work for defaults.
Is this something that is going to be added?

That I do hope will be added since the only way to replicate the
functionality is to drop, readd and repopulate a table.

Greg


pgsql-general by date:

Previous
From: "Mitch Vincent"
Date:
Subject: Re: Index on a function(field)
Next
From: Gilles DAROLD
Date:
Subject: Oracle to pg update