473,881 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resetting AUTO_INCREMENT after deleting records

1 New Member
I add a column named deptid in my dept table which is auto incremented.
After adding 3 records I deleted those records and inserted another record.
But it take the deptid as 4. I want it to start from 1.
If U know how to do this pls help.

Best Regards
Aug 30 '07 #1
3 1680
code green
1,726 Recognized Expert Top Contributor
After adding 3 records I deleted those records and inserted another record.
But it take the deptid as 4. I want it to start from 1.
OK but why? This is what auto-number does.
If you want to define the id yourself, don't use auto-number.
Aug 30 '07 #2
13,262 MVP
I add a column named deptid in my dept table which is auto incremented.
After adding 3 records I deleted those records and inserted another record.
But it take the deptid as 4. I want it to start from 1.
If U know how to do this pls help.

Best Regards
See the post #2 by Atli in this thread.
Aug 30 '07 #3
5,821 Recognized Expert Expert
Note that MySQL doesn't care whether the ID of the first record is 1, 6 or 548633. Forcing MySQL to reset the AUTO_INCREMENT value of a table will not improve performance.
Aug 30 '07 #4

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

Similar topics

by: Pjotr Wedersteers | last post by:
I have a table with quiz questions. Each question has a unique ID, based on an auto_increment field. Now I've discovered that with deleting rows from the table the deleted ID's are not reissued. Makes sense, just thought of that a bit late. How can I simply re-index or update or how one would call it, the columns holding the ID numbers ? Is there a ready-made mysql command or do I have to load all rows in PHP and modify where necessary ?...
by: Miguel Perez | last post by:
Hi everyone: Does anyone know how to reset the auto_increment value of certain table. Any ideas or sugestions Greetings in advance _________________________________________________________________ Únete al mayor servicio mundial de correo electrónico:
by: Dark Matt | last post by:
I'm looking at setting up two mysql servers in replication with both being masters. The most obvious snag in this scenario is auto_increment, as disconnections between servers could allow user interaction to generate duplicate keys. In a moment of zen I thought, "What if one server dealt only in even numbers, and the other only in odd numbers?" This solution would keep things simple and manageable, while also keeping the servers off...
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 (top>down). Then I erase those 5. Then I add a new record with a blanco first value. It will get number 6.
by: Mark | last post by:
This question refers to a main form with a continuous form subform. After an error occurs after entering several records in the subform, how can I delete all the data in the main form and all the records in the subform? I have tried undoing both the main form and the subform and I have tried deleting the record in the main form. Thanks! Mark
by: KC | last post by:
Hello, I am using Access 2002. WinXP, Template from MS called Orders Mgmt DB. I have tweaked this DB to work for our small co. It has worked pretty well up until I made the mistake of deleting about 80 records from the Orders table. 80 out of a 1000 records. Now our data entry form shows our customer addresses, but not customer order history. When looking at all of the tables, customer, payments, orders, they still have all of the...
by: rameshkumarc | last post by:
i m having one table with column (sno,name,addr,age)like that...i set the sno as auto_increment as well as primary key.........i m deleting all the records in the table...if i m inserting the new records the sno was not starting form 1..it's starting from old maximum value that i deleted.....i need to start the auto_increment from 1...can any one plz give the solution for my pbm?..
by: bcm | last post by:
I am migrating a database to MySQL 5.0. Several tables should have their primary key as an auto_increment integer. The database being copied has records with the primary key beginning with zero (0). These keys are foreign keys so it is not desirable to change their values. Here is what I have been trying: (1) Truncate table <tablename>; (2) Alter table <tablename> modify recid integer not null default 0; (3) <insert rows into table>...
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night) and the 'employee name'. There is another table which assigns an ID to the Shifts, i.e. 1,2 and 3 for morn, eve & night shifts respectively. From the mother table, the incentive is calculated datewise for each employee as per his shift duty. In...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.