DiigIT | IT Community
No Profile Image
Welcome Guest
New User? Register | Login

Auto_Increment Value

By: | 18 Feb 2009 4:25 pm

I recently changed hosting companies and recreated my MySQL database with all tables and data. Several tables use an Auto_Increment field as my PrimaryKey, (one up increment)

How can I determine the next value to make sure the trigger was not reset to 0 which will create a duplicate Primary Key, rejecting the record? I`m using phpMyAdmin from the cpanel.

Any help will be appreciated.

Comments

mysql_insert_id will tell you what the last entry was. To my knowledge, there is nothing that will tell you what the next id will be.

There is no reason that the increment will return to 0 unless you truncate the table or you are using your own programatic incrementer instead of mysql`s auto_increment.

By: | 18 Feb 2009

When I login to phpMyAdmin and view the table structure, a column `NextAutoIndex` is provided. This gave me the next sequence number for my Auto_Increment. All tables were the one-up number of the last record entered. This is correct and will prevent a new record from being rejected because of a duplicate Primary Key.

Thanks for all the help.

By: | 18 Feb 2009

Leave a comment

Enter the text in the image
img
Can't read?
Type the characters you see in the picture below.


Close Move