Interview Question in SQL Server Indexing


 

Interview Question :: Add Auto_Increment to MySQL using PHPMyAdmin (2.10.1)


I'm attempting to add the "auto_increment" option to an existing row in an existing table (containing data). The row NEWS_ID is int(10) and is indexed. I'm using the following command

ALTER TABLE ytc_news MODIFY news_id AUTO_INCREMENT;

and getting the following error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AUTO_INCREMENT' at line 1

What am I doing wrong?

Thanks.

d.dub/
Answers to "Add Auto_Increment to MySQL using PHPMyAdmin (2.10.1)"
RE: Add Auto_Increment to MySQL using PHPMyAdmin (2.10.1)?

You must also make news_id a primary key



Try this query



alter table `ytc_news`, modify `news_id` int(10) AUTO_INCREMENT , add primary key(`news_id`);
 
Vote for this answer ::  
Update Alert Setting