+ 5
Is there any way to undo a delete if you accidentally delete a table?
27 Antworten
+ 27
(related to what @Akshay said) please pay attention to the meaning of "delete a table": if you run "delete from table" you'll delete the records in that table, which can be undone via a rollback statement. If you run "truncate table" you'll also delete the records, but with no chance to rollback the operation. If you run "drop table" you'll delete the records AND the table structure, and also no rollback is possible.
+ 7
yes , by "rollback" command...you can recover the deleted data....but if you use "truncate"/"drop" command "rollback" will not work.
+ 5
Yes, ROLLBACK. However, this can only be used in what are call Transactions, multiple statements in one.
EG:
BEGIN TRAN
SELECT * yadayada
SELECT * yadayada
COMMIT TRAN
+ 4
if u had given BEGIN TRANSACTION
.
.
.
Then ROLLBACK can b used to get back d deleted table.
if not then it is permanently gone..#RIP
+ 3
if you havent wrapped the query in a begin tran/commit tran/rollback tran then the transaction has commited, meaning you will have to restore from backup and rebuild the table data
+ 3
use in all your sql scripts, run the begin tran first, then the delete statement after that you n have two options commit to save the changes to the table or rollback to undo the changes: begin tran. e.g.:
begin tran
--
delete from table_name;
--
commit
--
rollback
+ 2
rollback command is use to undo ur work done bt it is used after commit command only
+ 2
Why was 'ashwath nm' downvoted?
The simple answer is indeed rollback in a transaction, but:
If you haven't started tran, can't, or you need to GO BACK A DAY (but before your last backup) because you royally screwed your DB, the only thing that's going to save you is the binary transaction log.
RAID won't help you. Backups won't help you. Transactions won't help you. If you lose data like this you may just kiss your job (or worse) goodbye.
+ 1
You may use the "Rollback" keyword
+ 1
simply put, nope
+ 1
you should use ROLLBACK
+ 1
you can use rollback command to undo ur work done
0
take a backup!
0
flashback table tablename to before drop;
0
note you should not have commit else ctrl-z will help
0
by using rollback u can call the previous statement for delete.but in this case using 'truncate ' it will not work!!!!
0
rollback command
0
ROLLBACK won't help if you COMMIT. If you want to retrieve the data after commit, use following :
SELECT * FROM table_name AS OF TIMESTAMP(SYSTIMESTAMP - INTERVAL '20' MINUTE);
You can adjust the time and get data upto the time mentioned in UNDO RETENTION in DB otherwise you will get snapshot not found error.
- 1
CTRL-Z helps. If you have an apple device, then you can download a keyboard with the ctrl key, but all usual Web functions work (copy, cut, paste) in the Code world.
- 2
Rollback is the way for getting back your deleted table. But if you truncate table it won't be able to perform Rollback on that.