在oracle中,date类型只支持到秒,不支持到毫秒,所以to_date()不能取到毫秒。
如要取到毫秒,可以使用timestamp类型 (需oracle 9i以上版本)。
timestamp是date的扩展类型,能支持到毫秒,毫秒的显示精度是6位,不过有效位是3位,即最大值达到999,满1000ms就进为1s。
示例:
select sysdate from dual;
select systimestamp from dual;
select to_date('2021-01-01', 'yyyy-mm-dd') from dual;
select to_date('2021-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss') from dual;
select to_timestamp('2021-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss') from dual;