Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (20.3k points)

I’m trying to modify a table to make its primary key column AUTO_INCREMENT after the fact. I have tried the following SQL, but got a syntax error notification.

ALTER TABLE document

ALTER COLUMN document_id AUTO_INCREMENT

Am I doing something wrong or is this not possible?

+--------------------+

| VERSION()          |

+--------------------+

| 5.0.75-0ubuntu10.2 |

+--------------------+

1 Answer

0 votes
by (40.4k points)

Try this code:

ALTER TABLE document MODIFY COLUMN document_id INT auto_increment

Related questions

+2 votes
1 answer
asked Jun 24, 2019 in SQL by Sammy (47.6k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.6k users

Browse Categories

...