需求背景:
表中需要增加修改时间字段 update_time
历史数据处理: 从print_date字段同步(print_date 存的是2020-11-12 09:56:48 格式的字符串)
1、增加字段:
alter table panda_test add column update_time datetime(0) DEFAULT null COMMENT '修改时间';
效果:
2、print_date 字段值赋给update_time 字段:
update panda_test set update_time = str_to_date(print_date,'%Y-%m-%d %H:%i:%s')
效果: