可用版本: Dev (3.21) | 最新 (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11

CURRENT_OFFSETTIME

适用于 ✅ 开源版   ✅ 专业版   ✅ 企业版

获取当前服务器时间,作为 SQL TIME WITH TIME ZONE 类型(由 java.time.OffsetTime 表示)。

这与 CURRENT_TIME 的作用相同,只是添加了强制转换,并且客户端类型表示使用 JSR-310 类型。

SELECT current_time;
create.select(currentOffsetTime()).fetch();

结果类似于

+--------------+
| current_time |
+--------------+
|     15:30:45 |
+--------------+

方言支持

此示例使用 jOOQ

currentOffsetTime()

翻译成以下特定方言的表达式

访问

cstr(TIME())

ASE, Aurora MySQL, MariaDB, MemSQL, MySQL, Snowflake

CAST(current_time() AS time with time zone)

Aurora Postgres, BigQuery, CockroachDB, DB2, Derby, DuckDB, Firebird, H2, HSQLDB, Hana, Postgres, Redshift, SQLite, Teradata, Trino, Vertica, YugabyteDB

CAST(CURRENT_TIME AS time with time zone)

ClickHouse

CAST(current_timestamp() AS time with time zone)

Databricks, Exasol

CAST(current_timestamp AS time with time zone)

Informix

CAST(CURRENT HOUR TO SECOND AS time with time zone)

Oracle

CAST(current_timestamp AS timestamp with time zone)

SQLDataWarehouse, SQLServer

CAST(convert(TIME, current_timestamp) AS time with time zone)

Sybase

CAST(CURRENT TIME AS time with time zone)
使用 jOOQ 3.21 生成。早期 jOOQ 版本的支持可能有所不同。 在我们的网站上翻译您自己的 SQL

反馈

您对此页面有任何反馈吗? 我们很乐意倾听!

The jOOQ Logo