How to find “holes” in a table

后端 未结 10 2234
野趣味
野趣味 2020-12-24 04:28

I recently inherited a database on which one of the tables has the primary key composed of encoded values (Part1*1000 + Part2).
I normalized that column, but I cannot ch

10条回答
  •  没有蜡笔的小新
    2020-12-24 05:04

    This solution doesn't give all holes in table, only next free ones + first available max number on table - works if you want to fill in gaps in id-es, + get free id number if you don't have a gap..

    select numb + 1 from temp minus select numb from temp;

提交回复
热议问题