Oracle 表删除大量数据后查询变慢问题
Oracle 表删除大量数据后,即使表中只有几行记录,但用select count(*) from table 来查询发觉都不会马上出来,原因是该表的空间大了,查询起来很慢。解决的方法是把该表所占用的表空间缩小,或者说释放表空间。
alter table XXXX move; 这样处理后就释放了表空间了。但是释放表空间后,表的行号rowid会发生变化,而基于rowid的索引则会变成无效。因此该操作后必须重建索引。否则会提示“ORA-01502: 索引'SMP.ITEMLOG_MID_IDX'或这类索引的分区处于不可用状态” 而重建索引的方法当然可以先drop掉再create ,但是这样太麻烦了,用alter index XXX rebuild 这样最快了,不会改变原来的索引结构。
来源:http://hi.baidu.com/bbz_dd_a/blog/item/1c962bf4b69666dff2d38588.html
相关文档:
第四章:索引
1.creating function-based indexes
sql> create index summit.item_quantity on summit.item(quantity-quantity_shipped);
2.create a B-tree index
sql> create [unique] index index_name on table_name(column,.. asc/desc) tablespace
sql> tablespace_name [pctfree integer] ......
今天刚装了 oracle
记录一部分代码 以备使用
cmd操作
连接数据库 sqlplus "用户名/密码"
不区分大小写
c/原词/修改后 修改sql语句
l数字 数字 显示几行到几号的sql语句
/执行
shutdown 关闭服务
startup 启动服务
save 路径/文件名.后缀 保存缓冲区sql语句
get 文件 ......
Oracle中分析表的作用
http://diegoball.javaeye.com/blog/568009
文章分类:数据库
1.分析更新表的统计信息,,有可能导致执行计划改变..
2.以的analyze table abc compute statistics;这条为例,生成的统计信息会存在于user_tables这个视图,查看一下select * from user_tables where table_name='ABC';
观察一下NUM_RO ......
在启动oracle服务时,首先会在服务端找
1.spfile<sid>.ora
用于启动例程,如果找不到spfile<sid>.ora,则使用服务端缺省的
2.spfile
来启动,如果缺省的spfile也找不到,则使用
3.init<sid>.ora
来启动例程,最后则是使用缺省的
4.pfile
.当然你也可以指定pfile来覆盖缺省spfile启动例程,或通过spfile= ......
分区表、分区索引和全局索引:
在一个表的数据超过过2000万条或占用2G空间时,建议建立分区表。
create table ta(c1 int,c2 varchar2(16),c3 varchar2(64),c4 int constraint pk_ta primary key (c1)) partition by range(c1)(partition p1 values less than (10000000),partition p2 values less than (20000000),part ......