Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to set a auto_increment to a desired value?

Posted on 2002-03-07
3
Medium Priority
?
722 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

715 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