Mike Nelson Mike Nelson - 2 months ago 9
MySQL Question

Alter table to modify column type not terminating

I'm new to SQL and have a test table in a database. I realized that my previous title size allocation was too small, so I want to increase it from a VARCHAR(120) to VARCHAR(500) by running the following command:

ALTER TABLE test MODIFY title VARCHAR(500);


But that statement never terminates, even though the table contains less than 20 entries.

Am I missing something here?

Edit: I was basing that command off of these answers, but I've also tried:

ALTER TABLE test MODIFY COLUMN title VARCHAR(500);


Which doesn't terminate either.

Answer

Since you are not getting a syntax error and you have only a small number of rows, the most likely reason is that there is another process that's holding a lock on this table. Please connect any other clients that you have open. This could be other instances of mysql work bench, a long running script, the django console and so many things.

Then try the query again. If that still doesn't work, try SHOW OPEN TABLES

https://dev.mysql.com/doc/refman/5.7/en/show-open-tables.html