mysql 建表时增加一个字段标识数据的更新时间

需求:

报表开发时,想要每一份数据打上标识已识别数据的更新时间

解决:

 CREATE TABLE `rep_makeloan_day` 
 (dt date DEFAULT NULL  comment '统计日期',
 capital_no varchar(50) DEFAULT NULL  comment '资金端',
 order_num_history int  DEFAULT NULL  comment '历史累计放款笔数',
 order_count_history int  DEFAULT NULL  comment '历史累计放款总笔数',
 order_per_history double  DEFAULT NULL  comment '笔数占比',
 amount_history int  DEFAULT NULL  comment '历史累计放款金额',
 amount_sum_history int  DEFAULT NULL  comment '历史累计放款总金额',
 amount_per_history double  DEFAULT NULL  comment '金额占比',
 update_time timestamp NOT NULL  DEFAULT CURRENT_TIMESTAMP comment '更新时间'
 ) comment='教育分期-资金端放款统计' ;
update_time timestamp NOT NULL  DEFAULT CURRENT_TIMESTAMP comment '更新时间'

注意:

insert into 数据的时候,要写上需要的字段,否则源数据字段和目标数据字段数量对不上。

INSERT INTO mysql_federated_34_104.report_db.rep_makeloan_day (
	dt,
	capital_no,
	order_num_history,
	order_count_history,
	order_per_history,
	amount_history,
	amount_sum_history,
	amount_per_history
) SELECT
	cast(dt AS date) dt,
	cast(capital_no AS VARCHAR(50)) capital_no,
	cast(order_num_history AS INT) order_num_history,
	cast(order_count_history AS INT) order_count_history,
	cast(order_per_history AS DOUBLE) order_per_history,
	cast(amount_history AS INT) amount_history,
	cast(amount_sum_history AS INT) amount_sum_history,
	cast(amount_per_history AS DOUBLE) amount_per_history
FROM……

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值