Oracle's fixed

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.