Oracle中日期时间字段的处理方案
在PL/SQL中对表中的日期字段赋值的方法:
(1)输入指定日期:
insert into StudentInfo (StuID,StuName,Birthday) values ('004','Jacky',to_Date('2009-3-8','yyyy-mm-dd'));(2)输入当前系统日期:
insert into StudentInfo (StuID,StuName,Birthday) values ('004','Jacky',sysdate);(3)显示当前日期:
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual; --注意:mm代表月份, mi代表分钟--或者:select to_char(sysdate,'yyyy-mm-dd hh:mi:ss') from dual;
(4)优化日期显示格式:
select id,extract(year from hiredate)||'年'||extract(month from hiredate)||'月'||extract(day from hiredate)||'日' from employee;