按照MySQL模式的示例执行输入时间后,提示时间戳非法,后查询文档,文档使用的是time_to_usec()的函数,执行没有问题。两个函数对于相同的时间转换后的值是不一样的。
2 个赞
mysql> select * from account;
+------------+-------+----------+---------------------+---------------------+
| account_id | name | balance | gmt_create | gmt_modified |
+------------+-------+----------+---------------------+---------------------+
| 1 | Allan | 10000.00 | 2025-03-10 17:07:50 | 2025-03-10 17:07:50 |
| 2 | Jack | 20000.00 | 2025-03-10 17:07:50 | 2025-03-10 17:07:50 |
| 3 | John | 10000.00 | 2025-03-10 17:07:50 | 2025-03-10 17:07:50 |
+------------+-------+----------+---------------------+---------------------+
3 rows in set (0.08 sec)
mysql> select * from account as of snapshot timestamp_to_scn('2025-03-16 14:52:00');
+------------+-------+----------+---------------------+---------------------+
| account_id | name | balance | gmt_create | gmt_modified |
+------------+-------+----------+---------------------+---------------------+
| 2 | Jack | 20000.00 | 2025-03-10 17:07:50 | 2025-03-10 17:07:50 |
| 3 | John | 10000.00 | 2025-03-10 17:07:50 | 2025-03-10 17:07:50 |
| 4 | Bart | 10000.00 | 2025-03-10 17:07:50 | 2025-03-10 17:07:50 |
| 1 | Allan | 10000.00 | 2025-03-10 17:07:50 | 2025-03-10 17:07:50 |
+------------+-------+----------+---------------------+---------------------+
4 rows in set (0.01 sec)
mysql> select * from account as of snapshot time_to_usec('2025-03-16 14:52:00') * 1000;
+------------+-------+----------+---------------------+---------------------+
| account_id | name | balance | gmt_create | gmt_modified |
+------------+-------+----------+---------------------+---------------------+
| 1 | Allan | 10000.00 | 2025-03-10 17:07:50 | 2025-03-10 17:07:50 |
| 2 | Jack | 20000.00 | 2025-03-10 17:07:50 | 2025-03-10 17:07:50 |
| 3 | John | 10000.00 | 2025-03-10 17:07:50 | 2025-03-10 17:07:50 |
| 4 | Bart | 10000.00 | 2025-03-10 17:07:50 | 2025-03-10 17:07:50 |
+------------+-------+----------+---------------------+---------------------+
4 rows in set (0.01 sec)
mysql>
mysql> select time_to_usec('2025-03-16 14:52:00') * 1000, timestamp_to_scn('2025-03-16 14:52:00');
+--------------------------------------------+-----------------------------------------+
| time_to_usec('2025-03-16 14:52:00') * 1000 | timestamp_to_scn('2025-03-16 14:52:00') |
+--------------------------------------------+-----------------------------------------+
| 1742107920000000000 | 1742107920000000000 |
+--------------------------------------------+-----------------------------------------+
1 row in set (0.00 sec)
mysql>
同学我试了下是一样的,5.7.25-OceanBase_CE-v4.3.4.0
有吧