Results 1 to 4 of 4

Thread: DB2 scripting

  1. #1
    Join Date
    Dec 2007
    Posts
    288

    Unanswered: DB2 scripting

    I have to do some timings on how long it takes to run a particular query from my desktop.

    I am running DB2 "Select * from myschema.mytable" from the DB2 Command line on my desktop.

    Is there anything I can add to this query to also give me the time it took the query to run?

    Like pipe the results (number of rows selected and elapsed time to run the query) to a file?

  2. #2
    Join Date
    Apr 2012
    Posts
    1,035
    Provided Answers: 18
    You did not mention what your desktop is!

    Is it Windows or Linux?

    Db2 is excellent for scripting.

    The command line lets you either pipe (with redirection) the result-sets to a file, or also let you use the -o options (to send the output to the named file).

    To time the query, the CLP does not have built-in timing features yet.

    But you can use operating system features for that (e.g. on Linux , the time command, or on Windows you could use cygwin to get the equivalent, other tools are available).

  3. #3
    Join Date
    Dec 2007
    Posts
    288
    I am actually querying against a Mainframe DB2 Table via the local DB2 Client on my WINDOWS laptop.

  4. #4
    Join Date
    Dec 2008
    Location
    Toronto, Canada
    Posts
    399
    Quote Originally Posted by itsonlyme44 View Post
    I am actually querying against a Mainframe DB2 Table via the local DB2 Client on my WINDOWS laptop.
    something like this:
    select current timestamp from sysibm.sysdummy1 - before your query
    select current timestamp from sysibm.sysdummy1 - after your query
    and find the difference
    DB2 9.5/9.7 on Unix/AIX 6.1/Linux

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •