oracle中CURRENT_TIMESTAMP和SYSDATE不同

2023-09-19数据库问题
7

本文介绍了oracle中CURRENT_TIMESTAMP和SYSDATE不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

在 oracle 10g 中执行此 SQL 后:

After executing this SQL in oracle 10g:

SELECT SYSDATE, CURRENT_TIMESTAMP  FROM DUAL

我收到这个奇怪的输出:

I receive this strange output:

时间差的原因是什么?服务器时间等于 SYSDATE 值

What is cause of the difference in time? The server time is equal of SYSDATE value

推荐答案

CURRENT_DATECURRENT_TIMESTAMP 返回会话时区中的当前日期和时间.

CURRENT_DATE and CURRENT_TIMESTAMP return the current date and time in the session time zone.

SYSDATESYSTIMESTAMP 返回系统日期和时间 - 即数据库所在的系统.

SYSDATE and SYSTIMESTAMP return the system date and time - that is, of the system on which the database resides.

如果您的客户端会话与数据库所在的服务器不在同一个时区(或者说它不是,通过您的 NLS 设置),混合 SYS*CURRENT_* 函数将返回不同的值.他们都是对的,他们只是代表不同的东西.看起来您的服务器处于(或认为是)+4:00 时区,而您的客户端会话处于 +4:30 时区.

If your client session isn't in the same timezone as the server the database is on (or says it isn't anyway, via your NLS settings), mixing the SYS* and CURRENT_* functions will return different values. They are all correct, they just represent different things. It looks like your server is (or thinks it is) in a +4:00 timezone, while your client session is in a +4:30 timezone.

如果时钟不同步,您可能还会看到时间上的微小差异,这在这里似乎不是问题.

You might also see small differences in the time if the clocks aren't synchronised, which doesn't seem to be an issue here.

这篇关于oracle中CURRENT_TIMESTAMP和SYSDATE不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

Mysql目录里的ibtmp1文件过大造成磁盘占满的解决办法
ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致...
2025-01-02 数据库问题
151

按天分组的 SQL 查询
SQL query to group by day(按天分组的 SQL 查询)...
2024-04-16 数据库问题
77

SQL 子句“GROUP BY 1"是什么意思?意思是?
What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)...
2024-04-16 数据库问题
62

MySQL groupwise MAX() 返回意外结果
MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)...
2024-04-16 数据库问题
13

MySQL SELECT 按组最频繁
MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)...
2024-04-16 数据库问题
16

在 Group By 查询中包含缺失的月份
Include missing months in Group By query(在 Group By 查询中包含缺失的月份)...
2024-04-16 数据库问题
12