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
----------
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
我这边测试没有问题
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)
ANALYZE TABLE example DELETE STATISTICS
analyze table example compute statistics for table;
---------- ---------- ------------ 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是个 分区表 造成的吧!
我记得是这样子的
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)
SELECT DBMS_METADATA.GET_DDL('TABLE', 'YOUR_TABLE_NAME', 'YOUR_SCHAME_NAME')
FROM DUAL;
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我这边似乎没问题呀
analyze table example delete statistics ;
analyze table example compute statistics for table;