Re: question re incrementing an integer field in a table.

From: Aleksej Trofimov <aleksej(dot)trofimov(at)ruptela(dot)lt>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: question re incrementing an integer field in a table.
Date: 2011-12-16 11:26:26
Message-ID: 4EEB2AE2.5000508@ruptela.lt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 12/16/2011 12:57 PM, richard terry wrote:
> Hope this question isn't too idiotic and makes sense.
>
>
> Is there a simple way to increment the value of an integer field in a table in
> sql without reading the fields value adding 1 and re-saving? (the field is not
> a primary key or any other sort of foreign key)
>
> regards
>
> richard
>
>
Try this

UPDATE tables SET inc=inc+1 WHERE key=ID;

--
Best regards

Aleksej Trofimov

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Marcus Engene 2011-12-16 17:14:17 External ordered set of id:s, want to preserve order
Previous Message Thomas Kellerer 2011-12-16 11:24:56 Re: question re incrementing an integer field in a table.