Solved

how can i reset my id numbers in mySQL so it starts to count from 1

Posted on 2008-10-23
5
312 Views
Last Modified: 2013-12-07
because i deleted some data in between because they were duplicate,  the id numbers are not exactly what i want which are is a 100 it is now a 1035 i tried this but didnt work ...help

ALTER TABLE property.property p set id AUTO_INCREMENT=1;
0
Comment
Question by:Lucinda08
  • 3
  • 2
5 Comments
 
LVL 26

Expert Comment

by:ushastry
Comment Utility
Try this...(backup before running below code incase restore)

Pls change these... ID - > your auto-increment column name
                               tableName -> change with actual table name


SET @var_name = 0;
UPDATE tableName SET ID = (@var_name := @var_name +1);
ALTER TABLE tablename AUTO_INCREMENT = 1;
0
 

Author Comment

by:Lucinda08
Comment Utility
thanks but  what is var_name
0
 
LVL 26

Expert Comment

by:ushastry
Comment Utility
Its a variable...
0
 

Author Comment

by:Lucinda08
Comment Utility
sorry i'm a beginner to this do you mean i should give var_name any name i want
0
 
LVL 26

Accepted Solution

by:
ushastry earned 500 total points
Comment Utility
User variables are written as @var_name, where the variable name var_name may consist of alphanumeric characters from the current character set, ., _, and $

e.g Lucinda08 or ushastry
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Creating and Managing Databases with phpMyAdmin in cPanel.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to recover a database from a user managed backup

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now