windonly 发表于 2013-1-27 04:35:26

Oracle SQL培训笔记[开发人员][三]

四 索引与分页--怎么样SQL运行的更快
<ol>    正确的使用索引
    Where条件落在索引上
    不要在where的=前使用函数,否则无法使用索引
    Is Null可能无法使用索引
    不正确的隐式转换可能不能使用索引
    如果能在索引获得数据,就不要回表
    如果是复合索引,注意第2个字段以后,可能使用不到索引    正确的使用hint
    如果有别名,一定要有别名
    格式如/*+ index(t index_name) */    无需回表查询的分页写法
    存在以下表T1(A,B,C,D) T1上有索引字段(B,C) .如果只是查B,C两个字段则:    <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee;">http://www.agoit.com/Images/OutliningIndicators/None.gifselect *
    http://www.agoit.com/Images/OutliningIndicators/None.gif  from (select tt.b, tt.c, rownum as rn
    http://www.agoit.com/Images/OutliningIndicators/None.gif          from (select t.b, t.c from t1 t where c = 2 order by t.c) tt
    http://www.agoit.com/Images/OutliningIndicators/None.gif         where rownum < 3)
    http://www.agoit.com/Images/OutliningIndicators/None.gif where rn > 1
页: [1]
查看完整版本: Oracle SQL培训笔记[开发人员][三]