From: | Michael Wood <esiotrot(at)gmail(dot)com> |
---|---|
To: | JORGE MALDONADO <jorgemal1960(at)gmail(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: STARTING SERIAL / BIGSERIAL FIELDS FROM 1. |
Date: | 2009-07-20 19:58:09 |
Message-ID: | 5a8aa6680907201258mc336287g708bd98793db73fe@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
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>
From | Date | Subject | |
---|---|---|---|
Next Message | Mike | 2009-07-20 20:45:31 | Re: How to insert data from a text file |
Previous Message | Michael Wood | 2009-07-20 19:43:44 | Re: how to ignore a column from pg_dump |