Search Postgresql Archives

Re: unique constraint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux