Search Postgresql Archives

Re: sequence

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Alain Roger" <raf.news@xxxxxxxxx> 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

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux