Re: Setting Sequence Values

Поиск
Список
Период
Сортировка
От Joshua D. Drake
Тема Re: Setting Sequence Values
Дата
Msg-id 20071221171055.5082a107@commandprompt.com
обсуждение исходный текст
Ответ на Setting Sequence Values  (Martin <martin@cornhobble.com>)
Список 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 по дате отправления:

Предыдущее
От: Martin
Дата:
Сообщение: Setting Sequence Values
Следующее
От: "Gregory Williamson"
Дата:
Сообщение: Re: Setting Sequence Values