2009/7/20 JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>:
> How can a serial or bigserial field start from 1 again?
> I need to manually remove all the records from a table and I need these kind
> of fields to start from 1 once again.
If you use pg_dump on the database you should see something like this:
SELECT pg_catalog.setval('table_column_seq', 123456789, true);
That means that the last value will be set to 123456789 if you restore
using this dump.
You can do something like this, except that you can't set it to 0, so
you need to do this instead:
SELECT pg_catalog.setval('table_column_seq', 1, false);
Then the next value used would be 1.
Michael Wood <esiotrot(at)gmail(dot)com>
In response to
pgsql-novice by date
|Next:||From: Mike||Date: 2009-07-20 20:45:31|
|Subject: Re: How to insert data from a text file|
|Previous:||From: Michael Wood||Date: 2009-07-20 19:43:44|
|Subject: Re: how to ignore a column from pg_dump|