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

Make an id field max(id)+1 rather than SERIAL

From: Rory Campbell-Lange <rory(at)campbell-lange(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Make an id field max(id)+1 rather than SERIAL
Date: 2002-09-19 14:14:17
Message-ID: 20020919141417.GB6565@campbell-lange.net (view raw or flat)
Thread:
Lists: pgsql-novice
I have problems after exporting then importing data into newly created
databases that the sequence and the indexed serial fields get out of
alignment.

I wonder if it isn't better to always simply insert ids using some sort
of function or other procedure to calculate on each insert a new unique
id number.

Is this feasible?

Thanks for any help.
Rory

-- 
Rory Campbell-Lange 
<rory(at)campbell-lange(dot)net>
<www.campbell-lange.net>

Responses

pgsql-novice by date

Next:From: Oliver ElphickDate: 2002-09-19 16:59:43
Subject: Re: Make an id field max(id)+1 rather than SERIAL
Previous:From: Ciprian PopoviciDate: 2002-09-19 10:39:46
Subject: Re: restricting similar rows

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