甲骨文 DBMS_UTILITY.GET_TIME

Oracle DBMS_UTILITY.GET_TIME

Question : 为什么我们将差值除以 100 得到以秒为单位的时间?

Start
Get current time(Start Time)
Perform logical transaction
Get current time(End Time)
Subtract End Time – Start Time
Divide it by 100 to get total time in seconds. (Why 100?)
Stop

试试下面的代码:

declare START_TIME PLS_INTEGER;
begin

    START_TIME := DBMS_UTILITY.GET_TIME;
    DBMS_OUTPUT.PUT_LINE('START_TIME-->'|| START_TIME);

    dbms_lock.sleep(10);
    DBMS_OUTPUT.PUT_LINE('DBMS_UTILITY.GET_TIME-->'|| DBMS_UTILITY.GET_TIME);
    DBMS_OUTPUT.PUT_LINE('execution time --> ' || (dbms_utility.get_time - start_time)/100);
end;

来自 the documentation(重点是我的):

This function determines the current time in 100th's of a second. This subprogram is primarily used for determining elapsed time. The subprogram is called twice – at the beginning and end of some process – and then the first (earlier) number is subtracted from the second (later) number to determine the time elapsed.

所以您除以 100 得到以秒为单位的程序持续时间,而不是百分之一秒。