tags:

views:

495

answers:

1

Does anyone know what pg_catalog.setval does?

I just did a dump off a PostgreSQL database and got lots of lines with that in it. Not sure what it's for.

+2  A: 

You might want to check the fine manual:

setval(regclass, bigint) bigint Set sequence's current value

Example usage:;

# create sequence x;
CREATE SEQUENCE

# select nextval('x');
 nextval
---------
       1
(1 row)

# select nextval('x');
 nextval
---------
       2
(1 row)

# select nextval('x');
 nextval
---------
       3
(1 row)

# select setval('x', 10000);
 setval
--------
  10000
(1 row)

# select nextval('x');
 nextval
---------
   10001
(1 row)

# select nextval('x');
 nextval
---------
   10002
(1 row)
depesz
Thanks, tried googling this and didn't come up with anything.