UPDATE DB CFG FOR SAMPLE USING locklist 50; UPDATE DB CFG FOR SAMPLE USING dft_degree 1; UPDATE DB CFG FOR SAMPLE USING maxlocks 22; UPDATE DB CFG FOR SAMPLE USING avg_appls 1; UPDATE DB CFG FOR SAMPLE USING stmtheap 2048; UPDATE DB CFG FOR SAMPLE USING dft_queryopt 5;
db2 connect to sample db2 runstats on table <schema>.org with distribution and indexes all db2 runstats on table <schema>.sales with distribution and indexes all db2 terminate
db2 connect to sample db2 -tvf <intall path>\EXPLAIN.DDL db2 terminate
在名为 query.sql 的文件中保存下列命令:
connect to sample set current explain mode explain select * from org a, staff b where a.deptnumb=b.dept and b.dept=15 set current explain mode no terminate
现在,按下列方式执行该文件:
db2 -tvf query.sql
上面将仅仅以解释模式编译查询。您将在屏幕上看到:
C:\>db2 -tvf query.sql connect to sample
Database Connection Information
Database server = DB2/NT 8.2.1 SQL authorization ID = SKAPOOR Local database alias = SAMPLE
set current explain mode explain DB20000I The SQL command completed successfully.
select * from org a, staff b where a.deptnumb=b.dept and b.dept=15 SQL0217W The statement was not executed as only Explain information requests are being processed. SQLSTATE=01604
set current explain mode no DB20000I The SQL command completed successfully.
C:\>db2 terminate DB20000I The TERMINATE command completed successfully.
Database server = DB2/NT 8.2.1 SQL authorization ID = SKAPOOR Local database alias = DUMMYDB
set current explain mode explain DB20000I The SQL command completed successfully.
select * from org a, staff b where a.deptnumb=b.dept and b.dept=15 SQL0217W The statement was not executed as only Explain information requests are being processed. SQLSTATE=01604
set current explain mode no DB20000I The SQL command completed successfully.
C:\>db2 terminate DB20000I The TERMINATE command completed successfully.