首页 > 技术文章 > db2数据库创建索引,删除索引,查看表索引,SQL语句执行计划以及优化建议

yinguojin 2018-05-03 15:58 原文

1、建立表索引

    create index 索引名 on 表名(列名,列名);

2、删除表索引

    drop index 索引名 on 表名;

3、查看表索引

    select * from sysibm.sysindexes where tbname='表名';   ---表名区分大小写

    或者在后台可以用:

    describe indexes for table 表名;

4、查看SQL语句执行计划

    db2expln -d 库名 -f test.sql -t -g -z ";" > test.exp

5、查看SQL语句索引优化建议

    db2advis -d 库名 -i test.sql

推荐阅读