A technical troubleshooting blog about Oracle with other Databases & Cloud Technologies.

Upgrade the database time zone (TZ) file using the DBMS_DST package in 19c.

3 min read
After upgrading database from 12c to 19c, you may need to upgrade database time zone file version. This step is not always mandatory, but it is recommended by pre-upgrade checker.

Useful info about its necessity from Oracle site: https://oracle-base.com/articles/misc/update-database-time-zone-file
Below recommend action is from preupgrade.jar information tool.
Upgrade the database time zone file using the DBMS_DST package.

The database is using time zone file version 14 and the target 19 release ships with time zone file version 32.

Oracle recommends upgrading to the desired (latest) version of the time zone file.  For more information, refer to "Upgrading the Time Zone File and Timestamp with Time Zone Data" in the 19 Oracle Database Globalization Support Guide.
The error that may customer received when he attempted to transport tablespaces from the source with DST V.32 to the target being on DST V.26:
ORA-39002: invalid operation
ORA-39405: Oracle Data Pump does not support importing from a source database with TSTZ version 34 into a target database with TSTZ version 32.
1. Check the current timezone file version
SQL> SELECT * FROM v$timezone_file;

FILENAME		VERSION     CON_ID
-------------------- ---------- ----------
timezlrg_14.dat 	     14 	 0
2. Startup database in upgrade mode:
SQL> shutdown immediate;
SQL> startup upgrade;
3. Start upgrade window:
SET SERVEROUTPUT ON
DECLARE
l_tz_version PLS_INTEGER;
BEGIN
l_tz_version := DBMS_DST.get_latest_timezone_version;
DBMS_OUTPUT.put_line('l_tz_version=' || l_tz_version);
DBMS_DST.begin_upgrade(l_tz_version);
END;

--output

l_tz_version=32
An upgrade window has been successfully started.

PL/SQL procedure successfully completed.
4. Check primary and secondary time zone versions:
SQL> SELECT PROPERTY_NAME, SUBSTR(property_value, 1, 30) value
FROM DATABASE_PROPERTIES
WHERE PROPERTY_NAME LIKE 'DST_%'
ORDER BY PROPERTY_NAME; 
 
PROPERTY_NAME        VALUE
------------------------ ----------
DST_PRIMARY_TT_VERSION   32
DST_SECONDARY_TT_VERSION 14
DST_UPGRADE_STATE    UPGRADE
5. Startup database in normal mode:
SQL> shut immediate;
SQL> startup;
6. Perform the upgrade:
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
  l_failures   PLS_INTEGER;
BEGIN
  DBMS_DST.upgrade_database(l_failures);
  DBMS_OUTPUT.put_line('DBMS_DST.upgrade_database : l_failures=' || l_failures);
  DBMS_DST.end_upgrade(l_failures);
  DBMS_OUTPUT.put_line('DBMS_DST.end_upgrade : l_failures=' || l_failures);
END;
/
 
 
Table list: "GSMADMIN_INTERNAL"."AQ$_CHANGE_LOG_QUEUE_TABLE_S"
Number of failures: 0
Table list: "GSMADMIN_INTERNAL"."AQ$_CHANGE_LOG_QUEUE_TABLE_L"
Number of failures: 0
Table list: "MDSYS"."SDO_DIAG_MESSAGES_TABLE"
Number of failures: 0
Table list: "DVSYS"."SIMULATION_LOG$"
Number of failures: 0
Table list: "DVSYS"."AUDIT_TRAIL$"
Number of failures: 0
DBMS_DST.upgrade_database : l_failures=0
An upgrade window has been successfully ended.
DBMS_DST.end_upgrade : l_failures=0
 
PL/SQL procedure successfully completed.
7. Check new settings:
SQL> SELECT * FROM v$timezone_file;
 
FILENAME        VERSION     CON_ID
-------------------- ---------- ----------
timezlrg_32.dat          32      0
 
 
SQL> COLUMN property_name FORMAT A30
COLUMN property_value FORMAT A20
SELECT property_name, property_value
FROM   database_properties
WHERE  property_name LIKE 'DST_%'
ORDER BY property_name;
 
PROPERTY_NAME              PROPERTY_VALUE
------------------------------ --------------------
DST_PRIMARY_TT_VERSION         32
DST_SECONDARY_TT_VERSION       0
DST_UPGRADE_STATE          NONE
Timezone file has been upgraded to version 32.