-6

I imported a very large file from CSV which did not have any primary key into a MySQL table. In PHPMyadmin I added another column to my table now, to create a primary key with autoincrement. The problem is that it is starting from 1.

I checked this question and found ALTER TABLE column AUTO_INCREMENT = 1000; which will reset the autoincrement again to start from 1000, but is it possible to create an autoincrement from a particular number like 3456 for MySQL after creation of table and data entry?

Community
  • 1
  • 1
jahajee.com
  • 3,683
  • 4
  • 21
  • 26
  • 7
    What about `ALTER TABLE column AUTO_INCREMENT = 3456;` ?? – Maarkoize Jan 08 '14 at 07:59
  • 2
    So replacing `1000` to `3456` is over your experience? – zerkms Jan 08 '14 at 08:02
  • Altering autoincrement after creation of table and AI column will affect the rows added after this, I was asking if it was possible 1. After I have added the rows without AI (importing of data) 2. Adding AI starting from a number to already added rows in 1 since it did not had AI in table. Thanks in advance. – jahajee.com Jan 08 '14 at 08:10

1 Answers1

-2

You can do so:

UPDATE table SET column = column + 3456;
웃웃웃웃웃
  • 11,829
  • 15
  • 59
  • 91
Hett
  • 3,484
  • 2
  • 34
  • 51
  • No, this will set the value of column to column + 3456 and has nothing to do with the auto_increment value. – Maarkoize Jan 08 '14 at 08:02
  • 1
    It seems people are right this is not a AI problem but numbering problem. I added another column with PK and AI and allowed it to start at 1. Later `UPDATE table SET column = column + 3456` did the trick followed by `ALTER TABLE column AUTO_INCREMENT = MAXIMUM NUMBER NOW` . Thankyou everyone and sorry for wrong phrasing of question ;-( – jahajee.com Jan 08 '14 at 08:46