MySql Auto Id unique update

Add Auto ID. Column in existing data’s table  

Step :1

ALTER TABLE `users` ADD COLUMN
(
    `userid` smallint(6) NOT NULL,    
) 

Step : 2 

UPDATE 'users', (SELECT @id := 0) dm
SET userid = (@id := @id + 1)

Step : 3

   Make it as primary field  
   
   Select table (users) > select a column (userid) > click the link primary
 

 

Advertisements