 |
|
Oracle SYSDATE different from Linux/UNIX date tips
Oracle Database Tips by Donald Burleson |
Question: What is the relationship between the Oracle
internal SYSDATE and the Linux OS date? How does Oracle collect
the SYSDATE from Linux and what Linux/UNIX files are involved?
Answer: Yes, the Oracle SYSDATE is collected form the Linux or UNIX
and Oracle notes "The SYSDATE function simply performs a system-call to the
Operating System to get the time (a "gettimeofday" call)".
Make sure that you have EXPORT $TZ in your /etc/timezone file.
Also see
notes on
changing the Oracle sysdate.
The SYSDATE and OS
date environment and it is controlled by several files and environment
variables, namely the Linux TZ environment variable and the /etc/timezone file.
Oracle has this note on SYSDATE and the Linux date:
To debug situations in which you have a unexplained difference between the
oracle sysdate and the system time you see on Unix, use the following
method:
telnet to the unix machine
connect using sqlplus in the telnet session:
1)) once through the listener using a tnsnames alias
$sqlplus
user/password@[tnsnames alias]
SQL>select to_char( sysdate ,'DD-MON-YY HH24:MI:SS') from dual;
2) once trough a "local" ORACLE_SID connection
$env | egrep 'ORACLE_SID'
$sqlplus user/password
SQL>select to_char( sysdate ,'DD-MON-YY HH24:MI:SS') from dual;
Check that the time in the banner of sqlplus ( SQL*Plus: Release 10.1.0.4.0
- Production on Wo Jan 11 15:05:46 2006 ) is reflecting the time based on
the current TZ set in the Unix (!) session.
If the results are different this means that the listener is started with a
different TZ then you current user environment. To resolve this simply stop
and start listener with the TZ you want to use. if you are using MTS then
you might see a correct result with a dedicated connection, in that case
stop and start also the database with the correct TZ.
 |
If you like Oracle tuning, see the book "Oracle
Tuning: The Definitive Reference", with 950 pages of tuning tips and
scripts.
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts. |