`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
这样来创建:创建时间和修改时间这两个字段的时候,就不需要用代码更新着两个字段的值了。在保存时候自动更新。
然后java中实体类配合@DynamicUpdate这个注解来使用(spring jpa用法)
创建数据库关于时间的小技巧
最新推荐文章于 2023-08-17 16:32:42 发布