Skip site navigation (1) Skip section navigation (2)

Re: STARTING SERIAL / BIGSERIAL FIELDS FROM 1.

From: Lacey Powers <lacey(dot)powers(at)commandprompt(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: STARTING SERIAL / BIGSERIAL FIELDS FROM 1.
Date: 2009-07-21 04:37:18
Message-ID: 4A6545FE.3060104@commandprompt.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hello Jorge,

An even easier way to accomplish this would be to use the following:

ALTER SEQUENCE <sequence_name> RESTART WITH 1;

As shown in the documentation, here:

http://www.postgresql.org/docs/8.3/interactive/sql-altersequence.html

Hope that helps. =)

Sincerely,

Lacey
> 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.
>  
> With respect,
> Jorge Maldonado


-- 
Lacey Powers

The PostgreSQL Company - Command Prompt, Inc. 1.503.667.4564 ext 104
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


In response to

Responses

pgsql-novice by date

Next:From: tgsDate: 2009-07-21 07:30:47
Subject: Re: trouble connecting to DB
Previous:From: MikeDate: 2009-07-20 20:45:31
Subject: Re: How to insert data from a text file

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group