Re: What is the best practise for "autonumbering"..?

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: What is the best practise for "autonumbering"..?
Дата
Msg-id 20030506114757.GB2076@dcc.uchile.cl
обсуждение исходный текст
Ответ на What is the best practise for "autonumbering"..?  ("Bjorn T Johansen" <btj@havleik.no>)
Список pgsql-general
On Tue, May 06, 2003 at 01:09:13PM +0200, Bjorn T Johansen wrote:
> Using Postgres' own serial type or handling the sequences manually?

Use the SERIAL type.  Just create a column with that type and omit it on
INSERT statements -- that way, the default value will be assumed, which
is the next value for the sequence.  You can't have trouble this way.

Note that you can also specify a value for the column in an INSERT (or
UPDATE) statement, and in that case the sequence won't be modified,
which can be a problem later when the sequence hits that value.  You can
also set the column to a number lower than the current value of the
sequence, of course.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
Dios hizo a Adán, pero fue Eva quien lo hizo hombre.


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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Timebased user access
Следующее
От: Andrass Ziska Davidsen
Дата:
Сообщение: Re: restoring ver 7.2 database