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

Re: where's the gap in the sequence ?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Zouari Fourat <fourat(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: where's the gap in the sequence ?
Date: 2005-03-20 05:46:26
Message-ID: 20050320054626.GB2886@wolff.to (view raw or flat)
Thread:
Lists: pgsql-novice
On Sun, Mar 20, 2005 at 05:17:03 +0100,
  Zouari Fourat <fourat(at)gmail(dot)com> wrote:
> Hello
> i have a column 'id' wich is a sequence incremented by 1
> i did a verification on my table and found that i probably got some
> lines deleted from the table.
> i compared the count(*) and the max(id) and found that there is a
> difference of 400 lines.
> how to seek that gap in my table ? i want to know wich id value every
> line from the 400 deleted lines got.
> how to do it ?
> thanks

If you are using 8.0.x, you can use the generate_series function to generate
the set of possible IDs and then use set difference (EXCEPT), a left
join or NOT EXISTS to remove the set of ids that were used.

In response to

pgsql-novice by date

Next:From: Michael FuhrDate: 2005-03-20 05:56:57
Subject: Re: where's the gap in the sequence ?
Previous:From: Zouari FouratDate: 2005-03-20 04:17:03
Subject: where's the gap in the sequence ?

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