Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2007
    Posts
    288

    Unanswered: db2expln and access plans

    DB2 V9.5 on windows....

    I know how to do an access plan against SQL text and get a graph back... how do I run it from the command editor and get the access plan back in text????

  2. #2
    Join Date
    Sep 2003
    Posts
    237
    db2expln -database crm -stmtfile q -terminator ";" -t > outputfile

    works in unix; must be similar in windows
    put your sql in stmtfile and end the sql with a ;
    crm is the database name; look at db2expln command
    mota

  3. #3
    Join Date
    Dec 2007
    Posts
    288
    Thanks! IS there a way to run a SHOW PLAN or EXPLAIN from the GUI and then save it to a file?????

  4. #4
    Join Date
    Dec 2007
    Posts
    288
    I am still kind of struggling with this.

    Developer sent me some poorly running SQL (he did not write it) and asked me to do an explain on the SQL for him.

    I can run it through access plans via the GUI - but that is graphical and I can't sent it to him.

    I think I need to use db2expln. I am running on DB2 V9.5 on wondows. From what I've read, it looks like db2expln is command line only.

    I'm read through the syntax for db2expln so many times ( in the manual ) that my head is spinning.

    Can anyone guide me as what I need to do in order to run this long-a** chunk of SQL through db2expln???

  5. #5
    Join Date
    Dec 2008
    Location
    Toronto, Canada
    Posts
    399
    Quote Originally Posted by itsonlyme44
    DB2 V9.5 on windows....

    I know how to do an access plan against SQL text and get a graph back... how do I run it from the command editor and get the access plan back in text????
    run it with -graph option and you will get a graph you can copy and paste
    DB2 9.5/9.7 on Unix/AIX 6.1/Linux

  6. #6
    Join Date
    Dec 2007
    Posts
    288
    I don't necessarily NEED a graph.. just not sure how to run the SQL that he sent me in the body of an email through DB2EXPN?

  7. #7
    Join Date
    Dec 2008
    Location
    Toronto, Canada
    Posts
    399
    Quote Originally Posted by itsonlyme44
    I don't necessarily NEED a graph.. just not sure how to run the SQL that he sent me in the body of an email through DB2EXPN?
    then dbamota explained it how to do it - put it in file, finish with ; and run explain.
    DB2 9.5/9.7 on Unix/AIX 6.1/Linux

  8. #8
    Join Date
    Dec 2007
    Posts
    288
    Thank you. I will try and figure it out

Posting Permissions

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