在日常项目中往往会要求时间要以毫秒值的形式插入Oracle数据库中,为此本人也费了不少周折,下面介绍两种形式:
形式一:
drop table table1;
create table table1 (id number(3),time timestamp);
insert into table1 values(3,systimestamp);
select trunc(extract(day from inter) * 24 * 60 * 60 +
extract(hour from inter) * 60 * 60 + extract(minute from inter) * 60 +extract(second from inter)) "seconds" from(
select time -
to_timestamp('1970-01-01 00:00:00.000000000', 'yyyy-mm-dd hh24:mi:ss.ff') inter from table1);
上一个SQL语句是以毫秒值的形式查询得出的结果,借此复杂的SQL语句就得出了毫秒值
形式二:
利用Java中System.currentTimeMillis()语句得出毫秒值(13位),然后再插入数据库中,是不是很简单啊。
。。。。。。。。。。。。。。。。。
由于本人能力有限,希望大神能对我写的内容批评指正,不胜感激!