I have many columns in a table with a name starting with field_t and I have to change that to field_c
For example, here is the ALTER TABLE statement for changing the name of one of the columns:
ALTER TABLE my_table CHANGE field_t_class field_c_class longtext;
How can I change all the columns that follow this pattern instead of doing it in a one by one basis?
You can generated the ALTERs like this
You’ll also need to append DATA_TYPE etc and based on this CHARACTER_MAXIMUM_LENGTH,
NUMERIC_PRECISION, NUMERIC_SCALE, CHARACTER_SET_NAME and COLLATION_NAME…