SQL> select count(*) from example;  COUNT(*)
----------
   9999519SQL> select num_rows , blocks , empty_blocks from user_tables where table_name=upper('example');  NUM_ROWS     BLOCKS EMPTY_BLOCKS
---------- ---------- ------------
        18         15            0SQL> analyze table example compute statistics for table;Table analyzed.SQL> select num_rows , blocks , empty_blocks from user_tables where table_name=upper('example');  NUM_ROWS     BLOCKS EMPTY_BLOCKS
---------- ---------- ------------
        18         15            0
这个num_rows为什么还是18

解决方案 »

  1.   

    楼主确定select count(*) from example;和select num_rows , blocks , empty_blocks from user_tables where table_name=upper('example');是指同一个用户下的example表吗?
    我这边测试没有问题
      

  2.   

    是在 test用户下的,是在同一用户下的测试!
      

  3.   

    SQL> show user
    USER is "TEST"
    SQL> select table_name from user_tables;TABLE_NAME
    ------------------------------
    CHAINED_ROWS
    INVALID_ROWS
    AAA
    EXAMPLESQL> select count(*) from example;  COUNT(*)
    ----------
       9999519SQL> select num_rows , blocks , empty_blocks from user_tables;  NUM_ROWS     BLOCKS EMPTY_BLOCKS
    ---------- ---------- ------------        18         15            0
    SQL> analyze table example compute statistics for table;Table analyzed.
    SQL> select num_rows , blocks , empty_blocks from user_tables;  NUM_ROWS     BLOCKS EMPTY_BLOCKS
    ---------- ---------- ------------        18         15            0
    从前example表中 是存在 18 条数据 
    昨天测试了,输入了 很多数据进去了,数据都很简单,但是analyze后结果如下
    表结构SQL> desc example
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     COL_1                                     NOT NULL NUMBER
     COL_2                                              NUMBER
     COL_3                                              TIMESTAMP(6)
      

  4.   

    先删除,再收集,试试
    ANALYZE TABLE example DELETE STATISTICS
    analyze table example compute statistics for table;
      

  5.   

    SQL> analyze table example delete statistics;Table analyzed.SQL> select num_rows , blocks , empty_blocks from user_tables;  NUM_ROWS     BLOCKS EMPTY_BLOCKS
    ---------- ---------- ------------        18         15            0SQL> analyze table example compute statistics for table;Table analyzed.SQL> select num_rows , blocks , empty_blocks from user_tables;  NUM_ROWS     BLOCKS EMPTY_BLOCKS
    ---------- ---------- ------------        18         15            0不会是我的example是个 分区表 造成的吧!
      

  6.   

    怎么查看呢
    我记得是这样子的
    create table example
    ( col_1 number constraint example_pk primary key using index tablespace tbsindex ,col_2 number , col_3 timestamp)
    partition by range(col_2)(
    partition part_1 values less than (10) tablespace example,
    partition part_2 values less than (20) tablespace example,
    partition part_3 values less than (maxvalue) tablespace tbsindex)
      

  7.   

    可以用下面的语句来查看
    SELECT DBMS_METADATA.GET_DDL('TABLE', 'YOUR_TABLE_NAME', 'YOUR_SCHAME_NAME')
    FROM DUAL;
      

  8.   


    create table example
    ( col_1 number constraint example_pk primary key using index tablespace tbs1 ,col_2 number , col_3 timestamp)
    partition by range(col_2)(
    partition part_1 values less than (10) tablespace example,
    partition part_2 values less than (20) tablespace example,
    partition part_3 values less than (maxvalue) tablespace tbs1);INSERT INTO example
    VALUES (1,2,SYSTIMESTAMP);
    INSERT INTO example
    VALUES (10,25,SYSTIMESTAMP);
    COMMIT;SELECT count(*) FROM example;
      COUNT(*)
    ----------
             2select num_rows , blocks , empty_blocks from user_tables where table_name=upper('example');
      NUM_ROWS     BLOCKS EMPTY_BLOCKS
    ---------- ---------- ------------
             2         10           14INSERT INTO example
    VALUES (11,36,SYSTIMESTAMP);
    INSERT INTO example
    VALUES (21,16,SYSTIMESTAMP);
    INSERT INTO example
    VALUES (31,96,SYSTIMESTAMP);
    COMMIT;SELECT count(*) FROM example;
      COUNT(*)
    ----------
             5select num_rows , blocks , empty_blocks from user_tables where table_name=upper('example');
      NUM_ROWS     BLOCKS EMPTY_BLOCKS
    ---------- ---------- ------------
             2         10           14analyze table example compute statistics for table;select num_rows , blocks , empty_blocks from user_tables where table_name=upper('example');
      NUM_ROWS     BLOCKS EMPTY_BLOCKS
    ---------- ---------- ------------
             5         15            9我这边似乎没问题呀
      

  9.   

    删除之前的统计信息,再收集
    analyze table example delete statistics ;
    analyze table example compute statistics for table;