HomeInterview QuestionsIf I use DELETE, is it possible to roll back?

If I use DELETE, is it possible to roll back?

🟢 Easy Conceptual Junior level
1Times asked
Jul 2026Last seen
Jul 2026First seen

💡 Model Answer

Yes, you can roll back a DELETE operation, but only if it is executed within a transaction that has not yet been committed. In most relational databases, DML statements like DELETE are automatically wrapped in a transaction when autocommit is disabled. The typical workflow is:

  1. Begin TransactionBEGIN; or START TRANSACTION;.
  2. Execute DELETEDELETE FROM table WHERE condition;.
  3. Decide – If the result is acceptable, COMMIT;; otherwise, ROLLBACK;.

If autocommit is enabled (the default in many clients), each DELETE is committed immediately, making rollback impossible unless you use a savepoint or the database supports a special rollback feature. Some databases (e.g., PostgreSQL, Oracle) allow you to create a savepoint before the DELETE and roll back to that point. In MySQL, you can use START TRANSACTION; and ROLLBACK; if the storage engine supports transactions (InnoDB). Always ensure that the table uses a transactional engine and that you have the necessary privileges to start transactions.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500