Do I need to reuse the numeric primary keys of deleted records in the database for future new records?

For example, if I have a field with an automatic number, I add new records without specifying this field, and let the database engine select it for me.
So, will he choose the number of the deleted record? If yes, when?

// SQL Server, MySQL.//

Follow-up question: What happens when the numbers for primary keys end in the database engine?

+5
source share
11 answers

. , , ( !)

+14

AFAIK, MySQL:

AUTO_INCREMENT InnoDB:

InnoDB . , InnoDB INSERT , .

. Innodb auto_increment.:

: innodb auto_increment .

+8

. , , .

+2

, , .

- , Oracle, - , .

, , .

+2

. , . (set identity_insert on SQL Server) , , .

+1

:

... " Oracle Sequences"

... " autonumber MySQL"

... ..

+1

, . (IN MSSQL ), :

- , ,

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

, , ... :)

+1

MySQL , truncate delete from where ( MySQL truncate).

+1

, , .

, GUID , Guid , , Guid , , , .

0

MySQL id-.

- . : , ..

, ... , , , , , , , .

, , , , , , , . .

0

, , account_id - arghhhh!!

0

All Articles