sql - 设置时间字段默认值为当前时间

1. MySQL

create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',

2. PG

  "create_time" timestamp(6) DEFAULT ('now'::text)::timestamp(6) with time zone,
更新操作好像要用到触发器,待补充

 

posted @ 2021-10-20 14:45  10132714  阅读(2569)  评论(0编辑  收藏  举报