Oracle adds date format data to the database

Insert system date
insert into student(sno,sname,birthdate) values ​​(007,'omit',sysdate);

Insert the date in the specified format of the Oracle database
insert into student(sno,sname,birthdate) values ​​(008,'Ding','18/November/2022');

Use to date() to insert dates in other formats (most commonly used)
insert into student(sno,sname,birthdate) values ​​(009,'Car',to_date('2022-11-18,'yyyy-MM-dd')) ;


ps: When querying date results for comparison, to_char() is used, pay attention to the distinction

  • For example: query user data whose entry date is greater than 2019-05-18 (the 0 in 05 cannot be omitted) 
  • select * from student where birthdate to_char(dt.dtdate,'YYYY-MM-DD'>='2019-05-18');

Guess you like

Origin blog.csdn.net/sinat_56238820/article/details/127916211