8.1.1.1. 转换为 OceanBase-MySQL

8.1.1.1.1. 时间日期函数

8.1.1.1.1.1. SYSTIMESTAMP

语法
SYSTIMESTAMP
描述
该函数返回系统当前日期和时间,返回值的秒的小数位包含 6 位精度,包含当前时区信息,依赖于当前数据库服务器所在操作系统的时区
参数解释

示例

-- 转换前Oracle SQL:
SELECT SYSTIMESTAMP,SYSTIMESTAMP(0),SYSTIMESTAMP(1),SYSTIMESTAMP(2),SYSTIMESTAMP(3),SYSTIMESTAMP(4),SYSTIMESTAMP(5),SYSTIMESTAMP(6),SYSTIMESTAMP(7),SYSTIMESTAMP(8),SYSTIMESTAMP(9) FROM DUAL;
SYSTIMESTAMP                 |SYSTIMESTAMP(0)              |SYSTIMESTAMP(1)              |SYSTIMESTAMP(2)              |SYSTIMESTAMP(3)              |SYSTIMESTAMP(4)              |SYSTIMESTAMP(5)              |SYSTIMESTAMP(6)              |SYSTIMESTAMP(7)              |SYSTIMESTAMP(8)              |SYSTIMESTAMP(9)              |
-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+
2026-03-04 16:33:18.183 +0800|2026-03-04 16:33:18.000 +0800|2026-03-04 16:33:18.200 +0800|2026-03-04 16:33:18.180 +0800|2026-03-04 16:33:18.184 +0800|2026-03-04 16:33:18.183 +0800|2026-03-04 16:33:18.183 +0800|2026-03-04 16:33:18.183 +0800|2026-03-04 16:33:18.183 +0800|2026-03-04 16:33:18.183 +0800|2026-03-04 16:33:18.183 +0800|

-- 转换后OceaBase-MySQL SQL:
SELECT current_timestamp(6),current_timestamp(0),current_timestamp(1),current_timestamp(2),current_timestamp(3),current_timestamp(4),current_timestamp(5),current_timestamp(6),current_timestamp(6),current_timestamp(6),current_timestamp(6) FROM DUAL;
current_timestamp(6)   |current_timestamp(0)   |current_timestamp(1)   |current_timestamp(2)   |current_timestamp(3)   |current_timestamp(4)   |current_timestamp(5)   |current_timestamp(6)   |current_timestamp(6)   |current_timestamp(6)   |current_timestamp(6)   |
-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
2026-03-04 16:33:18.183|2026-03-04 16:33:18.000|2026-03-04 16:33:18.100|2026-03-04 16:33:18.180|2026-03-04 16:33:18.183|2026-03-04 16:33:18.183|2026-03-04 16:33:18.183|2026-03-04 16:33:18.183|2026-03-04 16:33:18.183|2026-03-04 16:33:18.183|2026-03-04 16:33:18.183|

警告

针对 OceanBase-MySQL-4.2.1 相关版本:

  1. 检查限制

    systimestamp(n) 中 n 的取值范围为 [0,9], 且必须为整数。不支持浮点数, 不支持类似 systimestamp(2+2) 的表达式。

  2. 精度限制

    源库 Oracle 中 systimestamp(n) 秒精度最高可达 9, 目标库 OB-MySQL 最多支持 6。

  3. 时区差异

    源库 Oracle 的 systimestamp(n) 包含时区信息, 转换到目标库 OB-MySQL 后不包含时区信息。

  4. DDL 支持范围

    仅支持如下语句转换:

    CREATE TABLE table_name (
        column_name TIMESTAMP DEFAULT SYSTIMESTAMP
    );
    

    不支持如下语句:

    ALTER TABLE table_name
    MODIFY column_name DEFAULT SYSTIMESTAMP;