Re: Setting Sequence Values - Mailing list pgsql-general

From Joshua D. Drake
Subject Re: Setting Sequence Values
Date
Msg-id 20071221171055.5082a107@commandprompt.com
Whole thread Raw
In response to Setting Sequence Values  (Martin <martin@cornhobble.com>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, 21 Dec 2007 23:57:21 -0000
Martin <martin@cornhobble.com> wrote:

> After porting tables and data from FrontBase I now find that I
> need to update all the values for the sequences that were created
> to reflect the data in the tables. Is there an easy way to do
> this?

Take a look at setval.

postgres=# select setval('foo_id_seq',(select max(id) from foo));
 setval 
- --------
    100
(1 row)

postgres=# select currval('foo_id_seq');
 currval 
- ---------
     100
(1 row)



Sincerely,

Joshua D. Drake


> 
> 
> ---------------------------(end of
> broadcast)--------------------------- TIP 5: don't forget to increase
> your free space map settings
> 


- -- 
The PostgreSQL Company: Since 1997, http://www.commandprompt.com/ 
Sales/Support: +1.503.667.4564   24x7/Emergency: +1.800.492.2240
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
SELECT 'Training', 'Consulting' FROM vendor WHERE name = 'CMD'


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHbGQhATb/zqfZUUQRAkGqAJ9jJMF/1aYY8q7L4C35ogVnSsowAACgnwH3
J0HpPengi7eo4n4b+YLaCZA=
=uQZ6
-----END PGP SIGNATURE-----

pgsql-general by date:

Previous
From: Martin
Date:
Subject: Setting Sequence Values
Next
From: "Gregory Williamson"
Date:
Subject: Re: Setting Sequence Values