表、索引结构如下:
desc s
Name
Type Nullable Default Comments
-------------- ------------ -------- ------- --------
F
NUMBER(10) 0
B
NUMBER(10)
0
C
NUMBER(10)
0
SQL>select index_name,index_type,table_name,uniqueness,status from user_indexes where table_name like 'S';
INDEX_NAMEINDEX_TYPE
TABLE_NAME
UNIQUENESSSTATUS
--------------------- --------------------------- ----------------------------------------
--------
IDX_S_F
NORMAL
S
NONUNIQUE VALID
SQL> select index_name,table_name,column_name,descend from dba_ind_columns where table_name='STOCK';
INDEX_NA
TABLE_NAME
COLUMN_NAME
DESCEND
-------------------- ------------------------- ------------------------------------ -------
IDX_S_F
S
F
ASC
数据库优化器是基于规则的。
问题:
当使用select *from s where bc查询没有结果返回;但是使用select *from s where bc and f=xxx有结果返回!!
开始怀疑索引或表有坏块,dbv检查未发现任何错误,annlyze index idx_s_f validate structure online,analyze table s validate structure online,未发现任何错,alert日志中也未发行任何错误。分析后,select *from s where bc、select *from s where bc and f=xxx均没有结果返回,正常了!
第二天,又出现了这个问题!分析表和索引后,问题没有解决!select *from s where bc查询没有结果返回;但是使用select *from s where bc and f=xxx有结果返回!!slect count(*) from s的纪录数为N。
于是,exp出表s,create table s1 as select * from s,备份表s,然后使用drop table s cascade constraints删除表,最后imp表s,导入后slect count(*) from s的纪录数为N,slect count(*) from s1的纪录数也一样是N!此时select *from s where bc、select *from s where bc and f=xxx均没有结果返回!!
请问:
1、导出、导入前后表的纪录数相同,应该说导出、导入前后的表s的内容是一样的,但是为什么select *from s where bc and f=xxx导出前有结果,导出后没有结果?会不会exp的时候有数据没有导出,而且select count(*) from s的时候也不会将这些数据统计进来?
2、相同的表s,select *from s where bc没有结果,select *from s where bc and f=xxx却有结果?如果只是索引的问题,那么导出、导入后的纪录数一样,查询的结果也一样才对!
请各位大虾帮忙分析一下!谢谢!
|