Re: sequence

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Alain Roger" <raf(dot)news(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: sequence
Date: 2007-12-09 15:51:32
Message-ID: 11021.1197215492@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Alain Roger" <raf(dot)news(at)gmail(dot)com> writes:
> to perform an autoincrement in my SQL queries...specially while i use insert
> into i do the following thing :

> INSERT INTO mytable VALUES
> (
> select nextval('users_user_id_seq'),
> ...
> );

> however this get the currentvalue + 1, or during creating the sequence i
> must say that start = 0.

Really? Works fine for me:

regression=# create sequence foo start with 10;
CREATE SEQUENCE
regression=# select nextval('foo');
nextval
---------
10
(1 row)

regression=# select nextval('foo');
nextval
---------
11
(1 row)

If you're initializing the sequence some other way, such as with
setval(), maybe you need to make use of the is_called option to setval().

regards, tom lane

In response to

  • sequence at 2007-12-09 15:41:01 from Alain Roger

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alain Roger 2007-12-09 15:56:56 Re: sequence
Previous Message Alain Roger 2007-12-09 15:41:01 sequence