473,385 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Re-use Auto_increment field

37
Hello, Can autonumber be reused if the record to which it was assigned is deleted?

I have a database table in which autonumber is used to uniquely identify records. However this table is appended and deleted with 10000 or more records daily. Is there a limit to autonumber in MySql becuse I may run out numbers at this rate!

Or would you suggest using an alternative datatype number automatically generated by the database to uniquely identify records?
Jan 26 '07 #1
3 2751
ronverdonk
4,258 Expert 4TB
No, you cannot re-use the auto_increment number just like that.

But why worry? With an INT auto_increment field with data type INT you can have 2147483647 as the maximum value.
10,000 changes per day, even inserts, means that you can live happily for the coming century.

And if you do get worried, and want to renumber the index:
- DROP the field you are auto_incrementing.
- ALTER the table to ADD the field again with the same attributes.
All existing rows are renumbered and the next auto_increment number will be equal to the row count plus 1.

Ronald :cool:
Jan 26 '07 #2
ozzii
37
No, you cannot re-use the auto_increment number just like that.

But why worry? With an INT auto_increment field with data type INT you can have 2147483647 as the maximum value.
10,000 changes per day, even inserts, means that you can live happily for the coming century.

And if you do get worried, and want to renumber the index:
- DROP the field you are auto_incrementing.
- ALTER the table to ADD the field again with the same attributes.
All existing rows are renumbered and the next auto_increment number will be equal to the row count plus 1.

Ronald :cool:
Thanks for the info. The drop and alter field solutions seems workable! Just one question the autonumber is also the primary key. Fortunatley the primary key isnt linked to any other table but what is the sql syntax to make it the primary key after it has been dropped and then added?
Jan 30 '07 #3
ronverdonk
4,258 Expert 4TB
Just using the standard alter table
Expand|Select|Wrap|Line Numbers
  1. ALTER TABLE xxx ADD COLUM id PRIMARY KEY AUTO_INCREMENT
statement.

Ronald :cool:
Jan 30 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
1
by: Chris | last post by:
Sorry to post so much code all at once but I'm banging my head against the wall trying to get this to work! Does anyone have any idea where I'm going wrong? Thanks in advance and sorry again...
11
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
10
by: James | last post by:
What is the best method for creating a Web Page that uses both PHP and HTML ? <HTML> BLA BLA BLA BLA BLA
8
by: Beowulf | last post by:
Hi Guru's, I have a query regarding using PHP to maintain a user profiles list. I want to be able to have a form where users can fill in their profile info (Name, hobbies etc) and attach an...
2
by: sky2070 | last post by:
i have two file with jobapp.html calling jobapp_action.php <HTML> <!-- jobapp.html --> <BODY> <H1>Phop's Bicycles Job Application</H1> <P>Are you looking for an exciting career in the world of...
5
by: Jamie Wright | last post by:
I have a problem with an HTML form. I have a form which I want to be able to type basic HTML code into it. When the submit button is selected the data is then previewed and added back into the text...
1
by: Brian | last post by:
I have an array like this: $events = array( array( '2003-07-01', 'Event Title 1', '1' //ID Number (not unique) ), array( '2003-07-02',
2
by: JW | last post by:
I wanted have this as part of a flood control script: <? echo ("Flood control in place - please wait " . $floodinterval . " seconds between postings."); sleep(5); // go back two pages echo...
2
by: Frans Schmidt | last post by:
I want to make a new database with several tables, so I did the following: <?php CREATE DATABASE bedrijf; CREATE TABLE werknemers (voornaam varchar(15), achternaam varchar(20), leeftijd...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.