I have a script that i use to load my data into my tables in Oracle (by a list of insert statements). How can i get the execution time of the entire loading process? I have tried with set timing on
, but that gives me a duration for each insert statement and not the entire process. The script is shown below:
spo load.log
prompt '**** load data ****'
set termout off
@@inserts.sql
commit;
set termout on
prompt '**** done ****'
spo off
exit;
Try this, add the following at the beginning and it remembers the current time:
Add this at the end and it calculates the time elapsed:
If you are on Unix, you can also do it like that:
It will print:
The first line gives the total execution time.
Not sure why everybody is making it so complex. Simple as:
It old question but i have found easy way to measure time of running a script in sqlplus. You just have to add this on the beginning
And this on the end of a script
More information about this command can be found at Oracle's SQL*Plus® User's Guide and Reference: Collecting Timing Statistics
What you're describing is essentially a way to audit the script's execution. Whether it's an elapsed time, or specific start and end times you're capturing you want to log them properly to see if things went well (or if not, why not).
Here's a template similar to what we use for capturing and logging all database activity we are implementing. We use it via
sqlplus.exe
for all DDL updates (e.g.CREATE TABLE
) and for inserts into setup tables.Place the body of your work here.