For a primary key of an integral type, why is it important to avoid gaps?

前端 未结 3 1620
栀梦
栀梦 2021-01-27 17:27

I am generating a surrogate key for a table & due to my hi/lo algorithm, everytime you reboot/restart the machine, gaps may appear.

T1: current hi = 10000000         


        
3条回答
  •  误落风尘
    2021-01-27 18:25

    Who told you this? A surrogate key has no meaning at all, so there can't be any gap. What is a gap in something that has no meaning? We use UUID's for our keys, something like this: 6ba7b812-9dad-11d1-80b4-00c04fd430c8. What would be the "next" key? Nobody knows, nobody cares. As long as it is unique, it's fine.

提交回复
热议问题