本文主要是介绍关于设置会话时区,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文档地址:http://docs.oracle.com/cd/B19306_01/server.102/b14225/ch4datetime.htm#i1006728
Setting the Session Time Zone
You can set the default session timezone with the ORA_SDTZ
environmentvariable. When users retrieve TIMESTAMP WITH LOCAL TIMEZONE
data, Oracle returns it in the users' session timezone. The session time zone also takes effect when aTIMESTAMP
value is converted to the TIMESTAMPWITH TIME ZONE
or TIMESTAMP WITH LOCAL TIMEZONE
datatype.
Note:
Setting the session time zone does not affect the value returned bytheSYSDATE
and SYSTIMESTAMP
SQL function. SYSDATE
returns the date and time of the operating system on which thedatabase resides, taking into account the time zone of the databaseserver's operating system that was in effect when the database wasstarted. The ORA_SDTZ
environment variable can be set to thefollowing values:
To set ORA_SDTZ
, use statements similar to one ofthe following in a UNIX environment (C shell):
% setenv ORA_SDTZ 'OS_TZ' % setenv ORA_SDTZ 'DB_TZ' % setenv ORA_SDTZ '-05:00' % setenv ORA_SDTZ 'Europe/London'
You can change the time zone for a specific SQL sessionwith the SET TIME_ZONE
clause of the ALTERSESSION
statement.
TIME_ZONE
can be set to the followingvalues:--TIME_ZONE可以设置为下列值:
-
Default local time zone when the session was started(
local
) -
Database time zone(
dbtimezone
) -
Absolute offset from UTC (for example,
'+10:00'
) -
Time zone region name (for example,
'Asia/Hong_Kong'
)
Use ALTER SESSION
statements similar to thefollowing:
ALTER SESSION SET TIME_ZONE=local; ALTER SESSION SET TIME_ZONE=dbtimezone; ALTER SESSION SET TIME_ZONE='+10:00'; ALTER SESSION SET TIME_ZONE='Asia/Hong_Kong';
You can find out the current session time zone by entering thefollowing query:
SELECT sessiontimezone FROM DUAL;
这篇关于关于设置会话时区的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!