修改库中所有表的某个类型,比如将double类型或者decimal中符合某些条件的字段形成批量的修改语句,同时排除掉指定的表
```sql
select
table_schema,
table_name,
column_name,
data_type,
numeric_precision,
numeric_scale,
column_comment,
concat('alter table ', table_name, ' modify column ', column_name, ' decimal(22,4)' , if(is_nullable = 'NO', ' not null', ''), ' COMMENT \'',column_comment,' \';')
from
INFORMATION_SCHEMA.columns t
where
table_schema = '库名'
and table_name not like 'act_%'
and (data_type = 'double'
or (data_type = 'decimal'
and numeric_scale>0
and numeric_precision>4
and numeric_precision <= 16))
order by
numeric_precision;
就可以得到批量的修改语句,执行即可