如果是9i,可以直接取到毫秒
如果是8i,可以得到1/100秒
如果需要得到毫秒,请用如下java过程
SQL>create or replace and compile
java source
named "MyTimestamp"
as
import java.lang.String;
import java.sql.Timestamp;
public class MyTimestamp
{
public static String getTimestamp()
{
return(new Timestamp(System.currentTimeMillis())).toString();
}
};
SQL>java created.
注:注意java的语法,注意大小写
SQL>create or replace function my_timestamp return varchar2
as language java
name 'MyTimestamp.getTimestamp() return java.lang.String';
/
SQL>function created.
SQL>select my_timestamp,to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') ORACLE_TIME from dual;
MY_TIMESTAMP ORACLE_TIME
------------------------ -------------------
2003-03-17 19:15:59.688 2003-03-17 19:15:59[@more@]
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14926/viewspace-804194/,如需转载,请注明出处,否则将追究法律责任。