now() default values are all showing same timestamp
我用列创建了表(类型:timestamp with timezone)并将其默认值设置为
我在单个函数中的单独语句中运行一系列插入,我注意到所有时间戳都等于(ms),是否为整个函数调用或事务缓存和共享了函数值?
这是预期和记录的行为:
从手册:
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.
如果您希望每次运行语句时都有更改,则需要使用
考虑PostgreSQL提供的其他选项之一,特别是
每个文件:
statement_timestamp() returns the start time of the current statement (more specifically, the time of receipt of the latest command message from the client)