Jump to content

MySQL primary key reusal


Al3x

Recommended Posts

For my primary key I have it NOT NULL and AUTO_INCREMENT...let's say it's INT(3) and call it "pkey".

 

This is fine and all...but say I have 20 rows with primary keys 1-20...and I delete #15.  When I add another, it gets the key 21.

 

What happens when I have done this like 300 times?...I may still have 20 rows of data, but eventually my pkey will auto_increment out of values.

 

Is the only way to avoid this by setting the pkey to something like INT(5) or more?  Is there a way to reuse unused primary keys automatically?

Link to comment
https://forums.phpfreaks.com/topic/94368-mysql-primary-key-reusal/
Share on other sites

You have a good point roopurt18.

 

Also BPops you are correct.  I just read this in a mysql book I bought:

 

"Integer with a range from -2147483648 to +2147483647.  The number that can be displayed is limited by length.  For example, if length is 4, only numbers from -999 to 9999 can be displayed, even though higher numbers are stored.

 

What does it mean "displayed" though?  Does that mean if I query it in PHP and output it...will it output the entire int?  Or is that considered a display?  I guess I can play around with that one.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.