Re: question re incrementing an integer field in a table. - Mailing list pgsql-novice

From Aleksej Trofimov
Subject Re: question re incrementing an integer field in a table.
Date
Msg-id 4EEB2AE2.5000508@ruptela.lt
Whole thread Raw
In response to question re incrementing an integer field in a table.  (richard terry <rterry@internode.on.net>)
List 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



pgsql-novice by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: question re incrementing an integer field in a table.
Next
From: Marcus Engene
Date:
Subject: External ordered set of id:s, want to preserve order