db2expln -d sccp -stmtfile queries.sql -terminator ';' -o explains.txt -graph -opids -setup SETUP.sql
# arquivo queries.sql deve conter somente consultas separadas por ;
#SETUP.sql é onde deve ter os SET CURRENT SCHEMA, RUNSTATS, etc.
db2expln -d sample -q "select ... " -terminal | egrep "Estimated Cost|Estimated Cardinality" | paste - -
db2expln -d $DBNAME -stmtfile $SQLFILE -terminator @ -terminal | egrep 'Estimated Cost|Estimated Cardinality|SQL[0-9]+N' | awk -F" =" '/Estimated Cost/ {{printf "E. Cost: %20.2f\n",$2;next}} /Estimated Cardinality/ {{printf "E. Card: %20.2f\n",$2;next}} {{printf "ERROR:\n%s\n",$0}}' | paste - - | awk '{{printf "(%3d) %s\n",NR,$0}}'