database with a unique and limited raw id

I need to create a database with a unique raw id field that is bounded by a limit, that is for example, a table with no more then 10 raw and with raw id 1,2,3…9,10.

This is simple if I use auto increment but after I have 10 raw and the user delete raw 5 and 7 for example and then create a new raw how can I find the next free number (5 in that example)?

Is there a simple way to implement it or I need to search the table for every entry?



Hope there is no other way, except finding the missing entry without executing a query.