Oracle Undo & Redo



Undo

Undo is used to refer to undo segments. So, what are segments? Segments refer to any type of thing that takes up storage space in the database ( like a table, or an index ). So an undo segment is a thing that takes up storage space and contains information about how data looked before you changed it.

Why? So that you can undo your changes ( rollback ). If you accidentally, or purposely deleted a bunch of data, you can rollback your changes and restore the table to the way it looked before you made the change. This is great if you are doing some development and want to change a bunch of data or test out some program that deletes or creates data. But that\'s not all it\'s good for, the undo is also used to allow other people that are connected to your database to see the previous version of the table you are in the process of modifying. Undo is also used for a couple of other things depending on the version of oracle you\'re using, but you get the idea of what Undo is now, so let\'s talk about redo.

 

Redo

Unlike undo segments that are stored in a tablespace and are similar to tables and indexes, redo logs are stored at the file system level and are used to store changes to the database as they happen.

The primary purpose of the redo logs are to record all changes to the database as fast as possible. So instead of searching for the correct tablespace and then searching for the table or index that needs to be changed, and then determining which portion of that table or index needs changing, and then finding the file at the operating system level that is related to the tablespace that needs to be modified and then updating that file. Oracle simply writes all changes to a redo log file. All changes, no mater what table, no matter what tablespace, no mater where on the filesystem the final change will need to be made.

This drastically improves I/O by allowing oracle to make quick writes to the OS and then batch processing all those changes so that the complicated updates can all happen at once.

It\'s called a redo log, because first oracle writes the data quickly to disk, then it later has to redo that change in the database proper. If the database crashes or has some other type of failure, oracle will first read the redo logs and apply all committed changes to their proper tablespaces / datafiles before opening the database up for regular use.


undo数据与redo数据的区别:
1.undo记录数据修改之前的操作,redo记录磁盘数据将要进行的操作.
2.undo用于数据的回滚操作,和实现一致性读,redo用于前滚数据库操作
3.undo存储在回滚段里,redo存储在重做日志文件里
4.undo用于在多用户并发的系统里保证一致性读,redo用于防止数据丢失




Undo Example

http://www.adp-gmbh.ch/ora/concepts/undo.html


参考:www.juliandyke.com/Presentations/TransactionInternals.ppt

转载于:http://blog.itpub.net/26687597/viewspace-1204081/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值