zoukankan      html  css  js  c++  java
  • dba_segments和dba_tables的不同

    create table tset as select * from dba_objects;

    select count(*) from tset;

    image

    select table_name,blocks,empty_blocks from dba_tables

    where table_name=’TSET’;

    image

    select segment_name,bytes,blocks,extents from dba_segments

    where segment_name=’TSET’;

    image

    问题来了,从dba_tables查询的blocks是空的,不按常理出牌啊~~什么鬼,什么鬼

    select table_name,blocks,empty_blocks,last_analyzed from dba_tables

    where table_name=’TSET’;

    image

    last_analyzed是分析的时间,为空值表示没有分析,所以执行语句分析下看看

    analyze table tset compute statistics;

    image

    1071+80=1151

    好像还少一个blocks,不是好像,就是少一个block。(先放这吧,不确定能找到为什么)。

    以上是我发现dba_tables和dba_segments的blocks数量不一致后查询网络得出的;

    大概个人总结以下:

    1.dba_segments中的blocks对应的是dba_tables中的blocks+empty_blocks

    2.

    The dba_tables view describes a "logical" structure whiledba_segments describes the "physical" data segment, like a data file.

    Also, columns like "blocks" are different between dba_tables and dba_segments.  In dba_tables, the "blocks" are calculated when you run dbms_stats, while indba_segments, "blocks" is the actual number of blocks used by the object on disk.

    (不解释,解释不了,我感觉只是感觉理解了),附上链接:http://www.dba-oracle.com/t_difference_dba_tables_dba_segments.htm

    oracle社区里有个不是使用CTAS创建表来说明dba_segments和dba_tables不一致的问题,我重复一遍吧:

    1. create table tset1 as select * from dba_objects where 1=0;

    select segment_name,bytes,blocks,extents from dba_segments

    where segment_name=’TSET1’;

    image

    插播:

    TSET1表的行数为0;默认分配一个extent,一个extent=8 blocks,一个block=8k(65536/1024/8)

    image

    oracle 11g不是延迟段分配的吗(默认)?

    image

    好吧,先不管了,下次再说吧,插播到此结束。

    2.select table_name,blocks,empty_blocks from dba_tables where table_name=’TSET1’;

       analyze table tset1 compute statistics;

       select table_name,blocks,empty_blocks from dba_tables where table_name=’TSET1’;

    image

    3.insert into tset1 select * from dba_objects;

       commit;

    image

    4. select segment_name,bytes,blocks,extents from dba_segments

        where segment_name=’TSET1’;

        select table_name,blocks,empty_blocks from dba_tables

        where table_name=’TSET1’;

        analyze table tset1 comput statistics;

        select table_name,blocks,empty_blocks from dba_tables

        where table_name=’TSET1’;

    image

    1068+83=1151,还是不等于1152

    附上oracle社区的链接,上面的测试结果是相等的哦!

    https://community.oracle.com/thread/582356?start=0&tstart=0

  • 相关阅读:
    delphi ios grid BindSourceDB bug
    RAD 10 C++Builder的bug
    Delphi Berlin 窗体代码分离风格 回到Delphi7传统风格
    delphi const的用法
    mysql的sql优化
    mysql如何使用索引index提升查询效率?
    移动端mobiscroll无法滑动、无法划动选值的问题
    html css的内联样式 内部样式表 外部样式表的优先级
    jfinal如何获取参数为数组的值
    jquery如何让checkbox如何取消勾选
  • 原文地址:https://www.cnblogs.com/cnmarkao/p/5147761.html
Copyright © 2011-2022 走看看