tags:

views:

330

answers:

3

i accidentally deleted some huge rows from a table..

How can i rollback it?

I executed the query using the putty ...

I'll greatful if any of me guide me safe out this hole..

+7  A: 

if you haven't made a backup, you are pretty much fudged.

Omry
So there is no way to undo that .... Oops i did it wrong..I should be using the select query to list what i should be deleting before actually executing the query.. A nice lesson leant to be more cautious
kvijayhari
sadly that's the case. and yes, it's always a good idea to verify with select before using delete or update.
Omry
This is one of the flaws of standard databases: They have no history, just a huge memory of "now".
Aaron Digulla
I would argue that it's by design. keeping a history is very expensive. you want your database to be fast, not forgiving.
Omry
A: 

If you didn't commit the transaction yet, try rollback. If you have already committed the transaction (by commit or by exiting the command line client), you must restore the data from your last backup.

Aaron Digulla
how to invoke rollbacki haven't exited from the command line client..
kvijayhari
by default the command line client uses auto commit after each command.
stmax
@Vijay: Just type "rollback;" + ENTER
Aaron Digulla
A: 

A "rollback" only works if you used transactions (http://www.sqlteam.com/article/introduction-to-transactions). That way you can group queries together and undo all queries if only one of them fails.

But if you already committed the transaction (or used a regular DELETE-query), the only way of getting your data back is to recover it from a previously made backup.

Select0r