This example shows the steps that you must follow in order to use the PlanExporter tool.
java org.apache.derby.tools.ij
CONNECT 'jdbc:derby:myDb;create=false';
CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(1); CALL SYSCS_UTIL.SYSCS_SET_XPLAIN_SCHEMA('MY_SCHEMA'); select * from my_table; CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(0); CALL SYSCS_UTIL.SYSCS_SET_XPLAIN_SCHEMA('');
select stmt_text, stmt_id from MY_SCHEMA.SYSXPLAIN_STATEMENTS; exit;
Now find the stmt_id of the executed query in the displayed results and note it down. It looks something like this:
9ac8804c-0129-cc31-ca9a-00000047f1e8
java org.apache.derby.tools.PlanExporter jdbc:derby:myDb MY_SCHEMA 9ac8804c-0129-cc31-ca9a-00000047f1e8 -html plain_html;
This command uses the default style sheet provided with Derby, and the HTML file will be generated at the same location, since the command does not specify a different path. The name of the HTML file generated is plain_html.html.