pg 库更新时间戳(TIMESTAMP)字段值

 测试部分:

SELECT TO_TIMESTAMP('2019-08-13 12:00:00.594', 'YYYY-MM-DD HH24:MI:SS') ,current_timestamp aa,to_char(now(), 'YYYY-MM-DD HH24:MI:SS'),to_date('2006-05-01 19:25:34', 'YYYY-MM-DD HH24:MI:SS'), order_no,order_status,updated_date FROM t_order WHERE cust_name in ('小青') AND order_status = '121'

-- 当前时间戳
select current_timestamp;

 

-- updated_date = TO_TIMESTAMP('2019-08-13 12:00:00.594', 'YYYY-MM-DD HH24:MI:SS')
-- updated_date = '2019-08-13 12:00:00.594'
--  updated_date = current_timestamp

 

更新字段部分:
--更新为当前时间戳
UPDATE t_order
SET order_status = 'draft',
 updated_date = TO_TIMESTAMP(
    to_char(
        CURRENT_TIMESTAMP,
        'YYYY-MM-DD HH24:MI:SS.MS'
    ),
    'YYYY-MM-DD HH24:MI:SS.MS'
)
WHERE
    cust_name IN ('小青')
AND order_status = '121'

 

 

参考连接:

https://www.jianshu.com/p/187e65fdcf4b

https://blog.csdn.net/snn1410/article/details/7741283

转载于:https://my.oschina.net/qimhkaiyuan/blog/3089534

你可能感兴趣的:(pg 库更新时间戳(TIMESTAMP)字段值)