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

Resetting sequence

From: "Keith Worthington" <keithw(at)narrowpathinc(dot)com>
To: "PostgreSQL Novice" <pgsql-novice(at)postgresql(dot)org>
Subject: Resetting sequence
Date: 2005-01-25 22:19:41
Message-ID: 20050125221536.M53757@narrowpathinc.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi All,

In my database I have the following table with a serial column.  All of the
data has been deleted from the table.  I would like to know if the sequence
can be reset such that the next time a record is written into the table it
will have a value of 1.  TIA

# \d inventory.tbl_detail
   Table "inventory.tbl_detail"
     Column     |          Type          | Modifiers                         
      
----------------+------------------------+----------------------------
 inventory_id   | integer                | not null default
nextval('inventory.tbl_detail_inventory_id_seq'::text)
 inventory_date | date                   | not null
 inventory_type | character varying(20)  | not null
 note           | character varying(511) | 
Indexes:
    "tbl_detail_pkey" PRIMARY KEY, btree (inventory_id)
Foreign-key constraints:
    "tbl_detail_fkey1" FOREIGN KEY (inventory_type) REFERENCES
inventory.tbl_type(inventory_type) ON UPDATE CASCADE ON DELETE RESTRICT


Kind Regards,
Keith

Responses

pgsql-novice by date

Next:From: Michael FuhrDate: 2005-01-25 23:04:42
Subject: Re: Resetting sequence
Previous:From: Gustavo PinsardDate: 2005-01-25 20:18:45
Subject: Re: postgresql or mysql or oracle?

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