Re: [GENERAL] How to increment by hand a sequence number.

From: Dustin Sallings <dustin(at)spy(dot)net>
To: Valerio Santinelli <tanis(at)mediacom(dot)it>
Cc: "pgsql-general(at)postgreSQL(dot)org" <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] How to increment by hand a sequence number.
Date: 1999-01-18 17:43:19
Message-ID: Pine.SGI.3.95.990118094241.1169A-100000@bleu.west.spy.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 18 Jan 1999, Valerio Santinelli wrote:

select max(id) from table;

will get you the max value, then you want to add one to that
number, and do this:

select setval('sequence_name', newvalue);

# I've exported a table from an existing MSAccess database to my
# PostgreSQL db.
# I use a serial ID on the table and now I'm getting errors when I add a
# new entry in the table if i don't specify the ID by hand (which should
# be placed automatically by the db since it's a serial).
#
# The exact error is this one:
#
# Cannot insert a duplicate key into a unique index.
#
#
# I think I should set the "last_value" field in the sequence to my real
# last value aon the ID field of the table, but Idon't know how to do it.
# Is there anybody who can help me ?
#
# Thanks
#
# Valerio Santinelli
# tanis(at)mediacom(dot)it
#
#
#
#

--
SA, beyond.com My girlfriend asked me which one I like better.
pub 1024/3CAE01D5 1994/11/03 Dustin Sallings <dustin(at)spy(dot)net>
| Key fingerprint = 87 02 57 08 02 D0 DA D6 C8 0F 3E 65 51 98 D8 BE
L_______________________ I hope the answer won't upset her. ____________

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert Chalmers 1999-01-18 22:33:01 Re: Was...[GENERAL] Checkboxes on MSAccess and PostgreSQL
Previous Message Byron Nikolaidis 1999-01-18 17:20:25 Re: [GENERAL] Checkboxes on MSAccess and PostgreSQL