Solved

how to set a auto_increment to a desired value?

Posted on 2002-03-07
3
720 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 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
insert row field data graphically 4 41
Where on a calculated field 1 39
restriction of entering a a page 5 44
How can I use javascript variable in mysql query 21 47
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

710 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