Oracle PL/SQL Tutorial/SQL PLUS Session Environment/Timezone
Версия от 13:45, 26 мая 2010; (обсуждение)
Содержание
Adjust your session time zone to -08:00
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.
Alter session to change the time zone
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>
Determine the database time zone:
SQL> select dbtimezone from dual;
DBTIME
------
+00:00
1 row selected.
SQL>
SQL>
SQL>
Determine your session time zone:
SQL>
SQL> select sessiontimezone from dual;
SESSIONTIMEZONE
------------------------------------------------------
-08:00
1 row selected.
SQL>
If your session time zone is not US/Central Standard Time (-06:00), alter your session to Central Standard time:
SQL>
SQL>
SQL> alter session set time_zone = "-06:00";
Session altered.
SQL>