In the work I encountered such a problem, the session table needs to use the timestamp field, in the timestamp field updates appear as a problem, such as the need to increase the duration of the session 1 hours.
The use of Systimestamp + 1/24 will lose the accuracy of the second, the feeling increases after the appearance of the date type. A study has found that Oracle has a function calledNumtodsinterval, this problem can be solved.The following two examples show how to use theThis function
Add an hour
SELECT To_char (systimestamp + numtodsinterval(1,' Hour '), ' Yyyy-mm-dd HH24:mi:ss:ff '), To_char (Systimestamp, 'yyyy-mm-dd HH24:mi:ss:ff') from dual;
Add one minute
SELECT To_char (systimestamp + numtodsinterval(1,'minut'), ' Yyyy-mm-dd HH24:mi:ss:ff '), to_ char (Systimestamp, ' Yyyy-mm-dd HH24:mi:ss:ff ') from dual;
The original interpretation of Numtodesignterval is as follows:
Numtodsinterval converts n to a INTERVAL day to SECOND literal. The argument n can is any number of value or an expression, the can is implicitly converted to a number value. The argument interval_unit can be of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 datatype. The value for interval_unit specifies the unit of N and must resolve to one of the following String values:
- ' Day '
- ' HOUR '
- ' MINUTE '
- ' SECOND '
From the interpretation, thenumtodsinterval function can also handle the increase in the value of day and Sesond, which is a very powerful function, as long as the "-" is added to the "-" before the number. In addition, if you need to increase the number of years or months,
To select the Numtoyminterval function
Oracle timestamp type added value problem