Find an interesting question today,
We know that the normal execution of select Sysdate from dual in the Oracle database can return the system time of the current host.
When the system time is changed normally, the corresponding query result becomes the modified system time.
Now there is a problem: the test system modified the host system time, database query select Sysdate from dual return time and the host time of the system is very different, further troubleshooting found that the return time is fixed.
The final discovery is that Oracle has parameters that allow sysdate to return to a fixed time for use by some test scenarios. The library is also because other testers have set the parameter, and other testers do not know, creating confusion.
The official description of this parameter is as follows:
Fixed_date enables you to set a constant date that sysdate would always return instead of the current date. To undo a fixed date setting, specify Fixed_date=none. This parameter was useful primarily for testing. The value can in the format shown above or in the default Oracle date format, without a time.
The simple test verifies that this is true:
--1. 设定会话时间显示格式:SQL> alter session set nls_date_format=‘yyyy-mm-dd hh24:mi:ss‘;Session altered.--2. 查询sysdate值,是正常返回数据库所在主机的系统时间:SQL>SQL> select sysdate from dual;SYSDATE-------------------2017-03-31 10:16:10SQL> /SYSDATE-------------------2017-03-31 10:16:18--3. 设置fixed_date参数为固定一个值:SQL> alter system set fixed_date = ‘2017-04-01 12:00:00‘;System altered.--4. 再次查询发现sysdate时间为设置的值,且固定不变:SQL> select sysdate from dual;SYSDATE-------------------2017-04-01 12:00:00SQL> /SYSDATE-------------------2017-04-01 12:00:00--5. 设置fixed_date参数为none,使sysdate正常显示所在主机的系统时间:SQL> alter system set fixed_date = none;System altered.SQL> select sysdate from dual;SYSDATE-------------------2017-03-31 10:20:11SQL> /SYSDATE-------------------2017-03-31 10:20:14SQL>
Oracle's fixed