+ 5

Is there any way to undo a delete if you accidentally delete a table?

19th Mar 2016, 8:24 PM
Eli Wolfe
Eli Wolfe - avatar
27 ответов
+ 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.
1st Dec 2016, 7:23 PM
Álvaro
+ 7
yes , by "rollback" command...you can recover the deleted data....but if you use "truncate"/"drop" command "rollback" will not work.
14th Aug 2016, 6:39 PM
AKSHAY MALVIYA
AKSHAY MALVIYA - avatar
+ 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
21st Mar 2016, 6:14 PM
Daniel Bell
Daniel Bell - avatar
+ 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
8th Dec 2016, 3:19 PM
rossi
rossi - avatar
+ 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
16th Apr 2016, 9:14 AM
Jonathan Baynes
+ 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
7th Dec 2016, 1:03 PM
Samuel Mayol
Samuel Mayol - avatar
+ 2
rollback command is use to undo ur work done bt it is used after commit command only
14th Dec 2016, 8:58 AM
Rincy Pereira
Rincy Pereira - avatar
+ 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.
15th Dec 2016, 10:14 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
You may use the "Rollback" keyword
10th Dec 2016, 6:19 PM
sagar seervi
sagar seervi - avatar
+ 1
simply put, nope
11th Dec 2016, 11:53 AM
Jacob Mathew
Jacob Mathew - avatar
+ 1
you should use ROLLBACK
12th Dec 2016, 7:16 PM
Linda Musitelli
Linda Musitelli - avatar
+ 1
you can use rollback command to undo ur work done
16th Dec 2016, 5:23 AM
Rincy Pereira
Rincy Pereira - avatar
0
take a backup!
3rd Dec 2016, 1:51 PM
Hozefa Ujjainwala
Hozefa Ujjainwala - avatar
0
flashback table tablename to before drop;
7th Dec 2016, 8:51 AM
Amit Kala
Amit Kala - avatar
0
note you should not have commit else ctrl-z will help
10th Dec 2016, 3:23 AM
Abhijit Singh
Abhijit Singh - avatar
0
by using rollback u can call the previous statement for delete.but in this case using 'truncate ' it will not work!!!!
15th Dec 2016, 9:06 PM
Nikhil
Nikhil - avatar
0
rollback command
29th Dec 2016, 1:16 PM
Saurabh Anand
Saurabh Anand - avatar
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.
26th Feb 2017, 11:35 AM
Ashish Shakya
- 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.
1st Dec 2016, 12:10 PM
Möbius
Möbius - avatar
- 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.
1st Jul 2016, 12:25 PM
Rutva Safi