mysql 批量更新数据库主键为int,bigint 类型,字段为自增类型

时间:2018-01-23 20:21:25   收藏:0   阅读:963
 select table_name,
       concat(‘alter table `‘,table_name,‘` MODIFY ‘, column_name, ‘ ‘, data_type ,‘ auto_increment;‘) as ‘query script‘
  from information_schema.columns c
 where c.table_schema = ‘pv_2‘
   and c.column_key =‘PRI‘ 
   and c.data_type in ( ‘int‘,‘bigint‘)
   and c.extra <> ‘auto_increment‘
 order by table_name;

 

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!