Oracle PL/SQL Tutorial/SQL PLUS Session Environment/Timezone
Содержание
Adjust your session time zone to -08:00
<source lang="sql">
SQL> SQL> SQL> create table t(
2 c1 timestamp with time zone, 3 c2 timestamp with local time zone 4 ) 5 /
Table created. SQL> SQL> insert into t (c1,c2)values( current_timestamp, current_timestamp ); 1 row created. SQL> SQL> select * from t;
C1
C2
26-OCT-09 10.31.38.026000 AM -06:00 26-OCT-09 10.31.38.026000 AM 1 row selected. SQL> SQL> alter session set time_zone = "-08:00"; Session altered. SQL> SQL> select * from t;
C1
C2
26-OCT-09 10.31.38.026000 AM -06:00 26-OCT-09 08.31.38.026000 AM 1 row selected. SQL> SQL> drop table t; Table dropped.</source>
Alter session to change the time zone
<source lang="sql">
SQL> create table myTable (
2 starts timestamp with local time zone );
Table created. SQL> SQL> insert into myTable (starts)
2 values (TIMESTAMP "2001-12-01 15:00:00.000000 EST");
1 row created. SQL> SQL> insert into myTable (starts)
2 values (TIMESTAMP "2001-12-01 17:00:00.000000 PST");
1 row created. SQL> SQL> insert into myTable (starts)
2 values (TIMESTAMP "2001-12-01 20:00:00.000000 GMT");
1 row created. SQL> SQL> alter session set time_zone = "-05:00"
2
SQL> column starts format a30 SQL> SQL> select starts from myTable;
STARTS
01-DEC-01 01.00.00.000000 PM 01-DEC-01 06.00.00.000000 PM 01-DEC-01 01.00.00.000000 PM 3 rows selected. SQL> drop table myTable; Table dropped. SQL> SQL></source>
Determine the database time zone:
<source lang="sql">
SQL> select dbtimezone from dual;
DBTIME
+00:00 1 row selected. SQL> SQL> SQL></source>
Determine your session time zone:
<source lang="sql">
SQL> SQL> select sessiontimezone from dual;
SESSIONTIMEZONE
-08:00 1 row selected. SQL></source>
If your session time zone is not US/Central Standard Time (-06:00), alter your session to Central Standard time:
<source lang="sql">
SQL> SQL> SQL> alter session set time_zone = "-06:00"; Session altered. SQL></source>