Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.
DELETE FROM sales;

And if there are no other uncommitted transactions on the sales table. Which statement is true about the DELETE statement?

  1. It removes all the rows in the table and deleted rows cannot be rolled back

  2. It removes all the rows as well as the structure of the table

  3. It would not remove the rows if the table has a primary key

  4. It removes all the rows in the table and deleted rows can be rolled back

of course, right answer lays between 1 and 4. I don't know whether the deleted data can be rolled back or not.

If any one knows, please help me. thanks.

share|improve this question
add comment

1 Answer

The delete statement without the where clause delete all rows in the table without change of table structure. If the delete statement is within a transaction, then it can be rollback before the transaction is committed.

If the delete transaction has been committed, the deleted transaction can't be rollback. Unless use of third party tool or restore the log backup to previous point if available.

share|improve this answer
    
You mean that if no error happened , the deleted data cannot be rolled back ,right? –  Vico_Wu Jun 25 '13 at 5:43
2  
@facebook-100005613813158: no. If it has been committed it can't be rolled back. –  a_horse_with_no_name Jun 25 '13 at 6:30
    
@facebook-100005613813158 You can rollback transaction with/without error as long as the transaction has not been committed. The key word is 'committed'. Please refer this msdn article for more information on transaction. msdn.microsoft.com/en-us/library/ms174377.aspx –  Travis Gan Jun 25 '13 at 14:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.