From: | Jeff Davis <pgsql(at)j-davis(dot)com> |
---|---|
To: | Michael Glaesemann <grzm(at)seespotcode(dot)net> |
Cc: | Jamie Kahgee <jamie(dot)kahgee(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: unique constraint |
Date: | 2010-10-20 20:43:17 |
Message-ID: | 1287607397.28384.98.camel@jdavis-ux.asterdata.local |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 2010-10-20 at 16:10 -0400, Michael Glaesemann wrote:
> Upgrade if you can. Otherwise you can do two updates when rearranging paragraphs. The first updates them to an "invalid" range which isn't used in "correct" data and so won't conflict with other values, and the second moves them back to the valid range of positions.
> Negative numbers are often used for this middle range.
The reason for the upgrade suggestion I believe was DEFERRABLE unique
constraints. These allow you to temporarily violate a unique constraint,
as long as it's correct at the end.
See:
http://www.postgresql.org/docs/9.0/static/sql-createtable.html
and look for "DEFERRABLE".
You can also consider a constraint trigger:
http://www.postgresql.org/docs/9.0/static/sql-createconstraint.html
Be careful to lock appropriately, however.
Regards,
Jeff Davis
From | Date | Subject | |
---|---|---|---|
Next Message | John R Pierce | 2010-10-20 20:58:59 | Re: postgre on virtual machine |
Previous Message | Michael Glaesemann | 2010-10-20 20:10:59 | Re: unique constraint |