• iot表输出按主键列排序,heap表不是


    <pre name="code" class="html"> create table t1  (id char(10) primary key,a1 char(10),a2 char(10));  
    
    
    begin 
    for i in 1 .. 1000
    loop 
    insert into t1 values(i,i,'a'||i); 
    end loop 
    ; 
    commit; 
    end; 
    
    
    BEGIN
      DBMS_STATS.GATHER_TABLE_STATS(ownname          => 'TEST',
                                    tabname          => 'T1',
                                    estimate_percent => 100,
                                    method_opt       => 'for all columns size repeat',
                                    no_invalidate    => FALSE,
                                    degree           => 8,
                                    cascade          => TRUE);
    END;
    / 
    
    
    
    
    create table t2 (id int primary key,a1 char(10),a2 char(10))organization index; 
    
    
    begin 
    for i in 1 .. 1000 
    loop 
    insert into t2 values(i,i,'a'||i); 
    end loop 
    ; 
    commit; 
    end;
    
    
    BEGIN
      DBMS_STATS.GATHER_TABLE_STATS(ownname          => 'TEST',
                                    tabname          => 'T2',
                                    estimate_percent => 100,
                                    method_opt       => 'for all columns size repeat',
                                    no_invalidate    => FALSE,
                                    degree           => 8,
                                    cascade          => TRUE);
    END;
    / 
    
    
    
    
    SQL> update t1 set id=1999 where id=999;
    
    已更新 1 行。
    
    SQL> commit;
    
    提交完成。
    
    SQL> update t2 set id=1999 where id=999;
    
    已更新 1 行。
    
    SQL> commit;
    
    提交完成。
    
    SQL> select * from t1 where id>990;
    
    ID	   A1	      A2
    ---------- ---------- ----------
    991	   991	      a991
    992	   992	      a992
    993	   993	      a993
    994	   994	      a994
    995	   995	      a995
    996	   996	      a996
    997	   997	      a997
    998	   998	      a998
    1999	   999	      a999
    1000	   1000       a1000
    1001	   10001      a1001
    
    已选择11行。
    
    SQL> select * from t2 where id>990;
    
    	ID A1	      A2
    ---------- ---------- ----------
           991 991	      a991
           992 992	      a992
           993 993	      a993
           994 994	      a994
           995 995	      a995
           996 996	      a996
           997 997	      a997
           998 998	      a998
          1000 1000       a1000
          1001 10001      a1001
          1999 999	      a999
    
    已选择11行。
    
    
    
    可以看到t1表是heap表输出不按主键排序
    
    t2表时iot表输出按主键列排序
    SQL>  select * from t1 where id>990 order by id ;
    
    
    ID	   A1	      A2
    ---------- ---------- ----------
    1000	   1000       a1000
    1001	   10001      a1001
    1999	   999	      a999
    991	   991	      a991
    992	   992	      a992
    993	   993	      a993
    994	   994	      a994
    995	   995	      a995
    996	   996	      a996
    997	   997	      a997
    998	   998	      a998
    
    
    已选择11行。
    
    
    SQL>  select * from t2 where id>990 order by id;
    
    
    	ID A1	      A2
    ---------- ---------- ----------
           991 991	      a991
           992 992	      a992
           993 993	      a993
           994 994	      a994
           995 995	      a995
           996 996	      a996
           997 997	      a997
           998 998	      a998
          1000 1000       a1000
          1001 10001      a1001
          1999 999	      a999
    
    
    已选择11行。


    
                                        
    
  • 相关阅读:
    CSLA.Net 3.0.5 项目管理示例 业务基类 Project.cs
    为什么我要写博客
    LINQ 标准的查询操作符 过滤 where、index1、OfType
    LINQ 概述和演变
    sl中几个简单变量的获取
    Rails存储库从SVN转向Git
    showcase测试界面
    Silverlight读取xml
    向silverlight传递自定义参数
    RadRails1.0降临——增加Profiler、CallGraph Analyzer和Rails Shell等新特性
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350605.html
Copyright © 2020-2023  润新知