How to set default timestamp to now() + n days?

前端 未结 2 1502
执念已碎
执念已碎 2021-01-26 07:38

I am developing an auth flow, where tokens with expiry timestamp are used. When a user logs in successfully, a token is generated and saved in the DB.

I know I can add

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-26 08:12

    eg:

    t=# create table t5(t timestamp default now() + '1 day'::interval);
    CREATE TABLE
    t=# insert into t5 default values;
    INSERT 0 1
    t=# select now(),t from t5;
                  now              |             t
    -------------------------------+----------------------------
     2018-01-26 08:05:06.641249+00 | 2018-01-27 08:04:57.035831
    (1 row)
    

提交回复
热议问题