Home » RDBMS Server » Server Administration » Query on Redo and Undo Basic concept (Oracle 10g R2 on HP-UX)
Query on Redo and Undo Basic concept [message #482975] Wed, 17 November 2010 05:42 Go to next message
OraKaran
Messages: 183
Registered: March 2008
Location: United Kingdom
Senior Member
Hello

Sorry if I haven't posted this query in the correct forum

Please help me understanding a redo/undo concept

please refer following data

create table t(n number);
insert into t values(10);
commit;


now I update as following

update t set n=20;


As per my understanding the before image i.e. n=10 is stored in undo (to be used for rollback, transcation recovery and even in instance recover but not in media recovery) and after image n=20 is stored in redo (to be used for various recovery purposes including media recovery in case of consistent backup)

So it is redo logs for rolling forward and undo for rolling back making transaction, db consistent

If my above understanding is true then what is meant by the term 'redo required for undo'?

Also
if there are 2 database db1 and db2 connected using database link where we are populating t1 table in db1 using t2 table in db2 using db link where redo and undo will be updated db1 or db2?

Regards,
OraKaran
Re: Query on Redo and Undo Basic concept [message #482976 is a reply to message #482975] Wed, 17 November 2010 05:52 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
For the 2nd point the answer would have to be - the db that's getting it's data modified. How could it be anything else?
Think of a db link as just another data source, using one doesn't change the mechanics of undo and redo.

For the 1st others can explain these concepts better than me.
Re: Query on Redo and Undo Basic concept [message #482978 is a reply to message #482976] Wed, 17 November 2010 05:57 Go to previous messageGo to next message
Michel Cadot
Messages: 68658
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
As per my understanding the before image i.e. n=10 is stored in undo (to be used for rollback, transcation recovery and even in instance recover but not in media recovery) and after image n=20 is stored in redo (to be used for various recovery purposes including media recovery in case of consistent backup)

Undo is also needed for recovery, this is why undo are protected by redo just like your data modification are protected by redo.
In short, (instance) recovery contains 2 parts:
1/ Roll forward all modification (redo them), committed or not
2/ Roll back the uncommitted modification (undo them)

Regards
Michel
Re: Query on Redo and Undo Basic concept [message #482979 is a reply to message #482978] Wed, 17 November 2010 06:00 Go to previous messageGo to next message
Michel Cadot
Messages: 68658
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
if there are 2 database db1 and db2 connected using database link where we are populating t1 table in db1 using t2 table in db2 using db link where redo and undo will be updated db1 or db2?

In db1, db2 is accessed in read only mode so no need of undo or redo.

Regards
Michel
Re: Query on Redo and Undo Basic concept [message #482980 is a reply to message #482975] Wed, 17 November 2010 06:13 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Just to add,
>>what is meant by the term 'redo required for undo'?
Undo will also generate redo.
Redo (information) are just change vectors that contains stuff about
how to do the change (like DML)
and
How to undo the change.
Re: Query on Redo and Undo Basic concept [message #482982 is a reply to message #482980] Wed, 17 November 2010 06:47 Go to previous messageGo to next message
OraKaran
Messages: 183
Registered: March 2008
Location: United Kingdom
Senior Member
Hello Experts

Thanks for your answers

While reading the anwsers I realized I must confirm my understanding of your answers and that of my question are matching!

I am extremly sorrying for not putting it in SQL way

Here is what I understand from your answers

1)
following describes what I meant
insert into db1 select * from db2@dblink.world;

for this I undrstand from advise is that
redo and undo generation would be for db1 only as db2 is referred as read only in above case

2)
In following case where remote table is updated, again redo and undo will be generated on db1 ONLY
Is that Correct?
insert into db1@dblink.world select * from db2;


3)
Since undo is protected by redo
can we say undo and redo generated by transcations will never be same and redo will be more as compared to undo, which will be closer to the amount of data modified?

Regards,
OraKaran
Re: Query on Redo and Undo Basic concept [message #482983 is a reply to message #482982] Wed, 17 November 2010 06:59 Go to previous messageGo to next message
Michel Cadot
Messages: 68658
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
1) OK
2) Almost, it depends on other statements of your transaction. In short, some information are needed in db2 (local database) to manage the distributed transaction. So in this case, there are data in redo of both databases, but only data in undo of db1.

3) Data in redo and undo are in different formats you cannot compare their size (if this is what you meant).

Regards
Michel

[Edit: typo]

[Updated on: Wed, 17 November 2010 08:26]

Report message to a moderator

Re: Query on Redo and Undo Basic concept [message #482985 is a reply to message #482975] Wed, 17 November 2010 07:45 Go to previous messageGo to next message
OraKaran
Messages: 183
Registered: March 2008
Location: United Kingdom
Senior Member
Thank you very much for clearing my doubts

It answers all my questions

Regards,
OraKaran

Re: Query on Redo and Undo Basic concept [message #483021 is a reply to message #482985] Wed, 17 November 2010 10:34 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>can we say undo and redo generated by transcations will never be same and redo will be more as compared to undo, which will be closer to the amount of data modified?
With regard to undo size, as a general rule with specific exceptions possible, INSERT produces the smallest UNDO, followed by UPDATE, with DELETE producing the biggest UNDO.
To UNDO an INSERT all that is needed is a DELETE by ROWID.
To UNDO an UPDATE another UPDATE with old values needs to be issued.
To UNDO a DELETE statement an INSERT with every column value is needed.
a REDO is same size as original SQL.
Re: Query on Redo and Undo Basic concept [message #483077 is a reply to message #483021] Thu, 18 November 2010 03:53 Go to previous message
OraKaran
Messages: 183
Registered: March 2008
Location: United Kingdom
Senior Member
Thanks BlackSwan

I got it right now

Regards
OraKaran
Previous Topic: Error...
Next Topic: Are parallel queries supported in Oracle XE
Goto Forum:
  


Current Time: Wed Jun 05 09:50:38 CDT 2024