now() default values are all showing same timestamp

。_饼干妹妹 提交于 2019-11-30 02:52:47

That is expected and documented behaviour:

From the manual:

Since these functions return the start time of the current transaction, their values do not change during the transaction. This is considered a feature: the intent is to allow a single transaction to have a consistent notion of the "current" time, so that multiple modifications within the same transaction bear the same time stamp.

If you want something that changes each time you run a statement, you need to use statement_timestamp() or even clock_timestamp() (again see the description in the manual)

now() or current_timestamp are STABLE functions returning the timestamp when the transaction started.

Consider one of the other options PostgreSQL offers, in particular statement_timestamp().
Per documentation:

statement_timestamp() returns the start time of the current statement (more specifically, the time of receipt of the latest command message from the client)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!