473,385 Members | 1,620 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.

How to reset AUTO_INCREMENT

228 100+
hi every1
i had deleted last 3 thousands records but auto increment still see it and dont increment in order (there is a gap between old stuff and new)

eg. the max value of 'id' is 12000 but when i insert next record its starting to count it as id=15000 (should be 12001)

how to make it count from 12001?
thanks a lot

jx2
Jun 6 '07 #1
2 2596
pradeep kaltari
102 Expert 100+
auto increment - how to reset it?
--------------------------------------------------------------------------------

hi every1
i had deleted last 3 thousands records but auto increment still see it and dont increment in order (there is a gap between old stuff and new)

eg. the max value of 'id' is 12000 but when i insert next record its starting to count it as id=15000 (should be 12001)

how to make it count from 12001?
thanks a lot

jx2
Hi,
As far as I know the only way to reset an auto increment column is by truncating the table.

For your problem: You can copy the records from your table to some temporary table, then TRUNCATE your table and load the data back to this table.

Regards,
Pradeep
Jun 6 '07 #2
Motoma
3,237 Expert 2GB
You can use the ALTER TABLE syntax to change the AUTO_INCREMENT value, but there is no reason to do this.
Jun 6 '07 #3

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

Similar topics

5
by: Eric Kincl | last post by:
Hey, I was wondering if it's possible to reset the "auto_increment" feature in MySQL. For example, if I have a database with a list that will change every year (the old list be completely flushed...
5
by: Paul Lamonby | last post by:
Hi, i want to create a unique serial number to my Db entries. I thought the best way would be to add the auto_increment primary key value to a string, then insert it into a table field...
2
by: Ittay Freiman | last post by:
i cannot set auto_increment to start from anything other than 1: mysql> create table test (id int unsigned not null auto_increment primary key); mysql> alter table test auto_increment=2; ...
2
by: Nico v. Rossum | last post by:
Hi *, How can I reset a AUTOINCREMENT column so it starts from 1 to n. TIA
2
by: Nico v. Rossum | last post by:
Hi * How can reset a auto_incremet collumn so it starts from 1 TIA
9
by: Bart Van der Donck | last post by:
Hello, The first column of my table is AUTO_INCREMENT. I fill my table with 5 records with a blanco value in their first field. The first column of my table will then hold the values 1,2,3,4,5...
0
by: Shailesh | last post by:
I made a MyISAM table on mysql 4.0.18 NT with auto_increment column started at 2147483646. The third row I insert fails as expected because the integer range is maxed out. However, if I delete...
2
by: hjyn | last post by:
Hi, how can I add char to auto_increment? For example, the auto_increment is for integer, I want to add a character at the front of that number. Ex: >create table abs (UserID INT(3) NOT NULL...
1
by: Phil Latio | last post by:
Newbie questions here... Reading the MySQL manual regarding InnoDB databases, can someone confirm that: 1. if the server is rebooted, AUTO_INCREMENT reverts back to 1? 2. what happens if the...
5
by: akapsycho | last post by:
I've got an index field which stores id numbers which are created by auto_incrementing and assigning that value as the id. ive already emptied out the values a few times since I'm testing, but I...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.