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

Поиск
Список
Период
Сортировка
От Thom Brown
Тема Re: question re incrementing an integer field in a table.
Дата
Msg-id CAA-aLv4TdHdwtR=ctijtv+P=mgre0iSwxCL3MuZ2Bthd_EpF7g@mail.gmail.com
обсуждение исходный текст
Ответ на question re incrementing an integer field in a table.  (richard terry <rterry@internode.on.net>)
Список pgsql-novice
On 16 December 2011 10:57, richard terry <rterry@internode.on.net> 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)

Hi,

You will either want to create a column with the pseudo type "serial"
or create a sequence and set the default value of an existing integer
column to use that sequence.  See the documentation:
http://www.postgresql.org/docs/current/static/datatype-numeric.html#DATATYPE-SERIAL

Regards

Thom

В списке pgsql-novice по дате отправления:

Предыдущее
От: richard terry
Дата:
Сообщение: question re incrementing an integer field in a table.
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Re: question re incrementing an integer field in a table.