I have huge table with 1 million records, i would like to modify some of the text columns to varchar column. Which is the best way to modify the columns.
- Alter table query with all modify columns
- Alter table queries with single modify column.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Definitely variant 1, because, as stated in the MySQL documentation,
In most cases, ALTER TABLE makes a temporary copy of the original table. MySQL waits for other operations that are modifying the table, then proceeds. It incorporates the alteration into the copy, deletes the original table, and renames the new one.
So, it’s better to have a single copy/wait for operations/delete old table/rename new one operation than multiple ones.