create rebuild rebuild onlne 索引的学习

------------create index
创建index在表上加的是4级锁,表数据修改、删除
创建索引的时候表上如果有活动事务,立刻提示资源忙
---------aler index test_1 rebuild online--------
rebuild需要2倍的索引所占的空间,当索引创建完毕后空间又被收回去。
rebuild的时候可以通过
  select sum(blocks) from dba_free_space where tablespace_namE='TEST'
  查看表空间剩余空间的变化
rebuild是扫描索引进行重建,rebuild online 是扫描基表进行重建
rebuild 索引对表加的是 4级索引,不能修改表的数据
rebuild online 加的是2级锁,可以修改数据。但rebuild online 会一直等待所有的表的活动事务结束才完成
如果表上有活动事务,rebuild 时候 立刻提示资源忙 。rebuild online 时候 一直等待的所有事务完成
位图索引不能使用ONLINE。
从索引开始rebuild online开始的那一刻起,oracle会先创建一个SYS_JOURNAL_xxx的系统临时日志表,结构类似于mlog$_表,通过内部触发器,记录了开始rebuild索引时表上所发生的改变的记录,当索引已经创建好之后,新数据将直接写入索引,只需要把SYS_JOURNAL_xxx日志表中的改变维护到索引中即可.
如果索引重建过程中,会话异常终止,在执行的时候肯能出现
ORA-08104: 该索引对象 52196 正在被联机建立或重建
10g下可以通过下面方法解决:
DECLARE
  RetVal BOOLEAN;
  OBJECT_ID BINARY_INTEGER;
  WAIT_FOR_LOCK BINARY_INTEGER;

BEGIN
  OBJECT_ID :=  52196;
--  我的数据库中非法索引的id为39852.
  WAIT_FOR_LOCK := NULL;

  RetVal := SYS.DBMS_REPAIR.ONLINE_INDEX_CLEAN ();
  COMMIT;
END;
/
-------------------ind$------------
dba_indexes的基表。里面包含dba_indexes没有的信息
flag:(索引的状态)
/* mutable flags: anything permanent should go into property */
/* unusable (dls) : 0x01 */
/* analyzed       : 0x02 */
/* no logging     : 0x04 */
/* index is currently being built : 0x08 */
/* index creation was incomplete : 0x10 */
/* key compression enabled : 0x20 */
/* user-specified stats : 0x40 */
/* secondary index on IOT : 0x80 */
/* index is being online built : 0x100 */
/* index is being online rebuilt : 0x200 */
/* index is disabled : 0x400 */
/* global stats : 0x800 */
/* fake index(internal) : 0x1000 */
/* index on UROWID column(s) : 0x2000 */
/* index with large key : 0x4000 */
/* move partitioned rows in base table : 0x8000 */
/* index usage monitoring enabled : 0x10000 */
514=0×202,表示该索引状态为index is being online rebuilt : 0×200 + analyzed : 0×02

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/69265/viewspace-470153/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/69265/viewspace-470153/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值