472,096 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 software developers and data experts.

How to recover deleted rows

hi

two days before arount 20,000 rows are manuly deleted, is there any way
to recover it back.
We have backup, that is 10 days old, Is there any way to recover only
that 20,000 rows,
Plz help me out ASAP.

Regards
Senthil Kumar.T

Sep 6 '06 #1
2 12426

se********@gmail.com wrote:
hi

two days before arount 20,000 rows are manuly deleted, is there any way
to recover it back.
We have backup, that is 10 days old, Is there any way to recover only
that 20,000 rows,
Plz help me out ASAP.

Regards
Senthil Kumar.T
Provided that no other rows other than the 20,000 ones were deleted
since then, you can write a trivial program that goes through all rows
available in the backup ( dumped into memory, files whatever) comparing
them with the ones you have left.

Find the ones that exist in the original set ( provided by the backup
) but do not exist on the current set ( the ones left after the manual
removal ).

Use INSERT IGNORE VALUES (...), (...), (...), (...)
to insert them back. Providing the column data for many rows ( as
opposed to just one ) for INSERT will considerably speed up the
process.

Sep 6 '06 #2
se********@gmail.com wrote:
hi

two days before arount 20,000 rows are manuly deleted, is there any way
to recover it back.
We have backup, that is 10 days old, Is there any way to recover only
that 20,000 rows,
Plz help me out ASAP.

Regards
Senthil Kumar.T
Yes, It may prove tedious, but step-by-step.

1. Create a temporary table using

CREATE TABLE temp AS SELECT * FROM realtable.

2. Delete the contents of the temp table.

3. Add the same primary index to temp

4. Load temp from your backup

5. Delete from the temp table where the primary key can be
found in the real table

What is left in the temp table are the deleted records

6. Insert them into the real table.
HTH
Jerry
Sep 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Grant | last post: by
1 post views Thread by Roberto La Forgia | last post: by
reply views Thread by mike_dba | last post: by
4 posts views Thread by =?Utf-8?B?cmFuZHkxMjAw?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.