Solved

how to set a auto_increment to a desired value?

Posted on 2002-03-07
3
709 Views
Last Modified: 2008-03-10
I have a table where one colum is uid, its a int not null auto_increment column , and it´s the primary key for that table, currently the highest value is 5284, but when I try to insert the next value, I get a huge number (2147483647) , not 5285, even phpMyAdmin in the propoerties of the table says "Next Autoindex 2,147,483,647" I´ve tried recreating the table and inserting the values again, and I still get that huge value when I try to insert a new one.

I´ve loooked in mySQL documentation on how to set a specific value in the next auto_increment value, but so far I´ve found nothing. Any clues?
0
Comment
Question by:aguilera007
3 Comments
 
LVL 5

Accepted Solution

by:
kelfink earned 200 total points
ID: 6848693
Generally, it looks like this works fine...

mysql> create table testinc ( i int not null primary key);
Query OK, 0 rows affected (0.00 sec)

mysql> insert into testinc values ( 5284 );
Query OK, 1 row affected (0.00 sec)

mysql> alter table testinc change i i int auto_increment not null;
Query OK, 1 row affected (0.03 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> insert into testinc values ( );
Query OK, 1 row affected (0.00 sec)

mysql> select * from boff;
+------+
| i    |
+------+
| 5284 |
| 5285 |
+------+
2 rows in set (0.00 sec)

-- BUT --
if, for some reason you need to change the number (as appears necessary in your case) you can set the next-number using:

alter table testinc auto_increment = 5285 ;

Incidentally, mysql seems to ignore my tested request to set the next number to a number which has already been used.

0
 
LVL 5

Expert Comment

by:andriv
ID: 6849472
What are the properties you set for that field.
0
 

Author Comment

by:aguilera007
ID: 6849508
Great help :D
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

15 Experts available now in Live!

Get 1:1 Help Now