How to Insert date-time type data in Oracle, as shown in the data table below
CREATE TABLE T (mydate date);
Sql> INSERT into T values (to_date (' 2015-1-30 12:20:33 ', ' yyyy-mm-dd HH24:MI:SS '));
Sql> Select To_char (mydate, ' Yyyy-mm-dd HH24:MI:SS ') from T;
To_char (mydate, ' YYY
-------------------
2015-01-30 12:20:33
Sql> INSERT into T values (to_date (' 2015-1-30 12:20 ', ' yyyy-mm-dd hh24:mi '));
1 rows have been created.
Sql> Select To_char (mydate, ' Yyyy-mm-dd HH24:MI:SS ') from T;
To_char (mydate, ' YYY
-------------------
2015-01-30 12:20:33
2015-01-30 12:20:00
Sql> INSERT into T values (to_date (' 2015-1-30 ', ' yyyy-mm-dd HH24 '));
1 rows have been created.
Sql> Select To_char (mydate, ' Yyyy-mm-dd HH24:MI:SS ') from T;
To_char (mydate, ' YYY
-------------------
2015-01-30 12:20:33
2015-01-30 12:20:00
2015-01-30 13:00:00
Sql> INSERT into T values (to_date (' 2015-1-30 ', ' yyyy-mm-dd '));
1 rows have been created.
Sql> Select To_char (mydate, ' Yyyy-mm-dd HH24:MI:SS ') from T;
To_char (mydate, ' YYY
-------------------
2015-01-30 12:20:33
2015-01-30 12:20:00
2015-01-30 13:00:00
2015-01-30 00:00:00
Sql> INSERT into T values (to_date (' 2015-1 ', ' yyyy-mm '));
1 rows have been created.
Sql> Select To_char (mydate, ' Yyyy-mm-dd HH24:MI:SS ') from T;
To_char (mydate, ' YYY
-------------------
2015-01-30 12:20:33
2015-01-30 12:20:00
2015-01-30 13:00:00
2015-01-30 00:00:00
2015-01-01 00:00:00
Sql> INSERT into T values (to_date (' n ', ' YYYY '));
1 rows have been created.
Sql> Select To_char (mydate, ' Yyyy-mm-dd HH24:MI:SS ') from T;
To_char (mydate, ' YYY
-------------------
2015-01-30 12:20:33
2015-01-30 12:20:00
2015-01-30 13:00:00
2015-01-30 00:00:00
2015-01-01 00:00:00
2015-01-01 00:00:00
6 rows have been selected.
Oracle uses 00 as the default value when omitting input parameters corresponding to HH, MI, and SS.
If the date data entered ignores the time portion, Oracle will set the time, minute, and second portions to 0, which means rounding to day.
Similarly, when the DD parameter is omitted, Oracle takes 1 as the default value for the day, which means that it is rounded to the month.
But it is strange to use the Select *from T, just query to date of the information, the second and second data can not see, but from the above data to see should be some ah, look at the master pointing.
Sql> select * from T;
MyDate
--------------
30月-January-15
30月-January-15
30月-January-15
30月-January-15
January-January-15
January-January-15
6 rows have been selected.
Instead of using select To_char (mydate, ' Yyyy-mm-dd HH24:MI:SS ') from T;
To_char (mydate, ' YYY
-------------------
2015-01-30 12:20:33
2015-01-30 12:20:00
2015-01-30 13:00:00
2015-01-30 00:00:00
2015-01-01 00:00:00
2015-01-01 00:00:00
Insert operation for Oracle Date