Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to set a auto_increment to a desired value?

Posted on 2002-03-07
3
Medium Priority
?
723 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 800 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating and Managing Databases with phpMyAdmin in cPanel.
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

876 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