oracle中 create index,关于create index 及 create index ... online .

目前正准备研究这个题目.

create  index

Oracle在使用create index来建立索引的时候在被索引的表中放置一个锁来防止用户改变表中的任何数据,如果一个table有5000万笔数据行,建立INDEX 需要大概30分钟,那么如果在生产系统运行的情况下建立这个index, 会出现什么情况,数据又是如何写入DB 以及如何被Lock机制协调处理的呢  (生产系统停止运行,table没有数据变化的情况使用create index 建立索引比较简单,不再讨论) ?

----  create index 建立索引,表保持联机时不能建立全部索引,这时候表中的这5000万笔记录不能被更新或删除,但是新insert 的数据是允许保存在table中的,只是在建立index期间新插入的数据行的index对应列没有被建立索引,索引建立完成之后,锁解除,然后insert 进来的数据行index对应列也应该是有index存在 ,还有这个所谓的Lock应该是行级排他锁还是表锁(这个时候应该是不能进行DDL 操作更改table 的) ?

create  index  ...... online  .

使用online 选项建立index 时候有很多的限制

ONLINE

Specify ONLINE to indicate that DML operations on the table will be allowed during creation of the index.

Restrictions on Online Index Building

Parallel DML is not supported during online index building. If you specify ONLINE and then issue parallel DML statements, Oracle returns an error.

You cannot specify ONLINE for a bitmap index or a cluster index.

You cannot specify ONLINE for a conventional index on a UROWID column.

For a unique index on an index-organized table, the number of index key columns plus the number of primary key columns in the index-organized table cannot exceed 32.

使用online 选项建立index 时候,允许留下可用表继续使用,那么在这个阶段 update, insert , delete 的这个table上的数据行及可能已经建立的对应的 index  如何处理 ?  这些变化部分会被存储到另外一个系统临时日志表吗 ?  等Index建立完成,变化部分重新维护到table及index中 ?

--------------------------------------------------------------------------------------------------------

其他相关资料 ( rebuild index 及 +online  ):

如果对已经建立的index 进行 rebuild online , 那么rebuild online 的那一刻起,  oracle会先创建一个SYS_JOURNAL_xxx的系统临时日志表,结构类似于物化视图日志表mlog$_表, 通过内部触发器, 记录了开始rebuild索引时表上所发生的改变的记录,当索引已经创建好之后, 新数据将直接写入索引,只需要把SYS_JOURNAL_xxx日志表中的改变维护到索引中即可 .

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值