Skip to main content

使用 CURRENT_TIME

以下原始 SQL 查询使用了 CURRENT_TIME 函数:

¥The following raw SQL query uses the CURRENT_TIME function:

prisma.$queryRaw`SELECT CURRENT_TIME;`

为什么这是一个问题

¥Why this is a problem

CURRENT_TIME 关键字仅返回时间(例如 14:30:00),不包含日期,因此不适用于日志记录或生成需要精确事件跟踪的时间戳等任务。它返回 timetz 类型的值,该类型是为了兼容 SQL 标准而添加的,但通常不建议使用。

¥The CURRENT_TIME keyword returns only the time (e.g., 14:30:00) without a date, making it unsuitable for tasks like logging or generating timestamps that require precise event tracking. It returns a value of type timetz, which was added for SQL standard compatibility but is generally discouraged.