For instance basically come with an auto-designated area, I add new records without indicating this area and let DB engine to choose it for me personally.
So, does it pick the amount of the erased record? If so, when?

// SQL Server, MySQL. //

Follow-up question: What happens when DB engine runs out of numbers to use for primary keys?

NO. statistical primary secrets won't used again, except you specify them by hand(you need to really avoid this!)

AFAIK, this could take place in MySQL:

How AUTO_INCREMENT Handling Works in InnoDB:

InnoDB uses the in-memory auto-increment counter as lengthy because the server runs. Once the server is stopped and restarted, InnoDB reinitializes the counter for every table for that first Place towards the table, as referred to earlier.

After a restart of server. Innodb reuse previously generated auto_increment values. :

Recommended fix: innodb table shouldn't lose the tabs on next number for auto_increment column after restart.

Is dependent around the auto-numbering system. If you are utilizing a sequence of any sort, the amounts of erased records won't get used again, because the sequence doesn't learn about them.

Generally, no, the amounts aren't used again.

However, you are able to -- in items like Oracle -- specify a sequence generator which cycles around and can reuse amounts.

Whether individuals are amounts of erased records or otherwise is the applications's problem.

Not particularly. If the bottom line is being read from the sequence or autoincrementing identity column the succession will just plug along and convey the following value. However, you are able to deactivate this (set identity_insert on on SQL Server) and set a variety you would like within the column as lengthy because it does not violate the originality constraint.

This must be made more precise:

... "with Oracle Sequences"

... "with MySQL autonumber posts"

... etc...

As lengthy while you produce the table properly you won't reuse amounts. Nevertheless, you can RESEED the identity column (IN MSSQL anyway) using the following:

-- Enter the amount of the final valid entry within the table not the following number for use

DBCC CHECKIDENT ([TableName], RESEED, [NumberYouWantToStartAt])

This really is obviously insane... and will not be done :)

MySQL won't reuse IDs unless of course you truncate the table or delete from the table without any where clause (by which situation MySQL, internally, simply does a truncate).

Yeah, it truly is dependent in route you create the id.

For instance if you work with a GUID because the primary key, most implementations of having a random new Guid will not pick another guid again, however it will given sufficient time and when the Guid isn't within the table the place statement goes fine, but when there's already a guid there you're going to get a principal key constraint breach.