Re: unique constraint when updating tables

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: gao iqiang <iqianggao(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: unique constraint when updating tables
Date: 2006-08-23 05:12:14
Message-ID: 20060823051214.GA16542@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Aug 22, 2006 at 08:39:00AM +0800, gao iqiang wrote:
> Hello,
> I met the following problem when i am using PostgreSQL as a backend
> database:
> I have a table "tabrel(a int primary key, b int)", and now there are for
> example 100 records with column 'a' be from 1 to 100. When i'm going to add
> one to each 'a' and intended to get 'a' varing from 2 to 101, i use SQL
> query as "update tabrel set a=a+1" , but i got " ERROR: duplicate key
> violates unique constraint tabrel_a_key".

Yes, PostgreSQL doesn't currently support deferred unique constraints.

You can find workarounds in the archives.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message surabhi.ahuja 2006-08-23 05:13:06 PSQLException: An I/O error occured while sending to the backend
Previous Message Gene 2006-08-23 04:10:56 Re: table partitioning