0

How can I alter the date and hour of the database? I don't want to alter the hour and date from the server, only in database.

10
  • 1
    Are you trying to set the value to a static value? Commented Aug 11, 2019 at 17:23
  • I my searches I found the parameter fixed_date but isn't this that I want. I am looking for some parameter that I can set the date and hour only in the instance or database (not in linux server for example) and can't be fixed
    – Astora
    Commented Aug 11, 2019 at 17:35
  • 1
    perhaps it would help if you explained your business problem instead of your preconceived technical solution . . .
    – EdStevens
    Commented Aug 11, 2019 at 17:39
  • Actually I'm studying for Oracle exam and in the exam has the topic Managing Data in Different Time Zones and because this I'm looking for some parameter to do some personal tests. isn't business problem but I guess that can help some day
    – Astora
    Commented Aug 11, 2019 at 17:45
  • I assume you like to change the database time zone (aka DBTIMEZONE) - however most likely it will not bring the effect you would expect, see stackoverflow.com/questions/29271224/… Commented Aug 11, 2019 at 18:48

1 Answer 1

1

ALTER DATABASE

set_time_zone_clause::=

enter image description here

set_time_zone_clause

This clause has the same semantics in CREATE DATABASE and ALTER DATABASE statements. When used in with ALTER DATABASE, this clause resets the time zone of the database. To determine the time zone of the database, query the built-in function DBTIMEZONE. After setting or changing the time zone with this clause, you must restart the database for the new time zone to take effect.

Oracle Database normalizes all new TIMESTAMP WITH LOCAL TIME ZONE data to the time zone of the database when the data is stored on disk.Oracle Database does not automatically update existing data in the database to the new time zone. Therefore, you cannot reset the database time zone if there is any TIMESTAMP WITH LOCAL TIME ZONE data in the database. You must first delete or export the TIMESTAMP WITH LOCAL TIME ZONE data and then reset the database time zone. For this reason, Oracle does not encourage you to change the time zone of a database that contains data.

For a full description of this clause, refer to set_time_zone_clause in the documentation on CREATE DATABASE.

SQL> select dbtimezone from dual;

DBTIME
------
+02:00

SQL> ALTER DATABASE SET TIME_ZONE = '-05:00';

Database altered.

SQL> select dbtimezone from dual;

DBTIME
------
+02:00

SQL> startup force
ORACLE instance started.

Total System Global Area  536868920 bytes
Fixed Size                  8898616 bytes
Variable Size             226492416 bytes
Database Buffers          293601280 bytes
Redo Buffers                7876608 bytes
Database mounted.
Database opened.
SQL> select dbtimezone from dual;

DBTIME
------
-05:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.