473,503 Members | 939 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

auto_increment

14 New Member
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?..
Mar 21 '07 #1
5 1046
bartonc
6,596 Recognized Expert Expert
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?..
You could DROP the table and recreate it. Should work.
Mar 21 '07 #2
rameshkumarc
14 New Member
if there is any other solution without dropping the table
Mar 21 '07 #3
write2ashokkumar
39 New Member
hi...

If u want to delete all the records from the table means, use the command "truncate".

syntax:

truncate table <table_name>;

after truncating the table, if u insert the record, the auto increment value
starts from 1.


Regards,
S.Ashokkumar.
Mar 21 '07 #4
write2ashokkumar
39 New Member
hi...

Another one method...

after deleting all the records, use the alter command to reset the auto increment value.

Ex: alter table tbl_xxx auto_increment = 1

Refer this link:
http://www.scriptygoddess.com/archives/2004/06/24/reset-autoincrement-value-in-mysql-tabl/

Regards,
S.Ashokkumar.
Mar 21 '07 #5
rameshkumarc
14 New Member
ya it's working now....thanks for ur solution mr.ashok kumar
Mar 21 '07 #6

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

Similar topics

5
3070
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...
4
1950
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....
2
14325
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
10193
by: Nico v. Rossum | last post by:
Hi * How can reset a auto_incremet collumn so it starts from 1 TIA
9
3311
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
1749
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
492
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
1713
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...
1
1606
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...
1
1309
by: mostafijur | last post by:
Hello, My database table containing a column name P_ID Field Extra = P_ID, Type = int(11), Null = NO, Key = PRI, Default = NULL, Extra = auto_increment
0
7203
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
7089
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
7339
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...
1
6995
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...
0
7463
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5581
agi2029
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,...
0
4678
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...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1515
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.