Preparing to update the time zone file
A time zone file upgrade has two separate phases: prepare and upgrade. While not required, we strongly
recommend that you perform the prepare step. In this step, you find out which data will be affected by
running the PL/SQL procedure DBMS_DST.FIND_AFFECTED_TABLES
. For more information about the
prepare window, see Upgrading the Time Zone File and Timestamp with Time Zone Data
To prepare to update the time zone file
-
Connect to your Oracle database using a SQL client.
-
Determine the current timezone file version used.
SELECT * FROM V$TIMEZONE_FILE;
-
Determine the latest timezone file version available on your DB instance.
SELECT DBMS_DST.GET_LATEST_TIMEZONE_VERSION FROM DUAL;
-
Determine the total size of tables that have columns of type
TIMESTAMP WITH LOCAL TIME ZONE
orTIMESTAMP WITH TIME ZONE
.SELECT SUM(BYTES)/1024/1024/1024 "Total_size_w_TSTZ_columns_GB" FROM DBA_SEGMENTS WHERE SEGMENT_TYPE LIKE 'TABLE%' AND (OWNER, SEGMENT_NAME) IN (SELECT OWNER, TABLE_NAME FROM DBA_TAB_COLUMNS WHERE DATA_TYPE LIKE 'TIMESTAMP%TIME ZONE');
-
Determine the names and sizes of segments that have columns of type
TIMESTAMP WITH LOCAL TIME ZONE
orTIMESTAMP WITH TIME ZONE
.SELECT OWNER, SEGMENT_NAME, SUM(BYTES)/1024/1024/1024 "SEGMENT_SIZE_W_TSTZ_COLUMNS_GB" FROM DBA_SEGMENTS WHERE SEGMENT_TYPE LIKE 'TABLE%' AND (OWNER, SEGMENT_NAME) IN (SELECT OWNER, TABLE_NAME FROM DBA_TAB_COLUMNS WHERE DATA_TYPE LIKE 'TIMESTAMP%TIME ZONE') GROUP BY OWNER, SEGMENT_NAME;
-
Run the prepare step.
-
The procedure
DBMS_DST.CREATE_AFFECTED_TABLE
creates a table to store any affected data. You pass the name of this table to theDBMS_DST.FIND_AFFECTED_TABLES
procedure. For more information, see CREATE_AFFECTED_TABLE Procedurein the Oracle Database documentation. -
This procedure
CREATE_ERROR_TABLE
creates a table to log errors. For more information, see CREATE_ERROR_TABLE Procedurein the Oracle Database documentation.
The following example creates the affected data and error tables, and finds all affected tables.
EXEC DBMS_DST.CREATE_ERROR_TABLE('
my_error_table
') EXEC DBMS_DST.CREATE_AFFECTED_TABLE('my_affected_table
') EXEC DBMS_DST.BEGIN_PREPARE(new_version
); EXEC DBMS_DST.FIND_AFFECTED_TABLES('my_affected_table
', TRUE, 'my_error_table
'); EXEC DBMS_DST.END_PREPARE; SELECT * FROMmy_affected_table
; SELECT * FROMmy_error_table
; -
-
Query the affected and error tables.
SELECT * FROM
my_affected_table
; SELECT * FROMmy_error_table
;