I have many tables with columns of varchar(45)
. Now I need them all to became varchar(128)
. Is there a way to do it without manually examining all 40 tables?
I found this question that touches similar topic, but how to do it with columns?
I have many tables with columns of varchar(45)
. Now I need them all to became varchar(128)
. Is there a way to do it without manually examining all 40 tables?
I found this question that touches similar topic, but how to do it with columns?
To obtain all columns that meets my needs, I can use:
SELECT table_name, column_name FROM information_schema.columns
WHERE table_schema LIKE "my_schema_name"
AND data_type = "varchar"
AND character_maximum_length < 50;
Now I need to use any programming language that can connect to MySQL, and in a loop execute:
ALTER TABLE table_name MODIFY column_name VARCHAR(128);