Questions tagged [rollback]

A rollback is reverting data to a previous state. Typically questions in this tag involve transactions in Relational Database Management Systems, where a ROLLBACK command is used to discard any changes to the data since a transaction started.

1545 questions
26
votes
2 answers

Transactional DDL workflow for MySQL

I was a little surprised to discover that DDL statements (alter table, create index etc) implicitly commit the current transaction in MySQL. Coming from MS SQL Server, the ability to do database alterations in a transaction locally (that was then…
sennett
  • 8,014
  • 9
  • 46
  • 69
26
votes
3 answers

Is there any way to rollback after commit in MySQL?

I did a big mistake that I updated a table without 'where' clause in MySQL :'( It is auto-committed. Is there any way to rollback from it?
Johnny Lim
  • 5,623
  • 8
  • 38
  • 53
22
votes
2 answers

MySQL rollback on transaction with lost/disconnected connection

I need to make MySQL server to rollback transaction immediately after its client disconnected, because each client works concurrently. The problem can be reproduced like these (using an innodb table type) On Client A: START TRANSACTION; SELECT…
qsoft
  • 424
  • 2
  • 5
  • 17
22
votes
3 answers

Is it a better practice to explicitly call transaction rollback or let an exception trigger an implicit rollback?

In the below code if any exception is thrown while executing the the SQL statements we should expect an implicit rollback on the transaction as the transaction was not committed, it goes out of scope and it gets disposed: using (DbTransaction tran =…
Elan
  • 6,084
  • 12
  • 64
  • 84
22
votes
6 answers

Automatic Rollback if COMMIT TRANSACTION is not reached

Consider the following: START TRANSACTION; BEGIN; INSERT INTO prp_property1 (module_name,environment_name,NAME,VALUE) VALUES ('','production','','300000'); /** Assume there is syntax error SQL here...**/ Blah blah blah DELETE FROM prp_property1…
Koekiebox
  • 5,793
  • 14
  • 53
  • 88
22
votes
3 answers

How to rollback nested transactions with Propagation.REQUIRES_NEW in integration tests

I have several integration tests for various services that extend the following baseclass: @ContextConfiguration(locations="classpath:applicationContext-test.xml") @TransactionConfiguration(transactionManager="txManager",…
esaj
  • 15,875
  • 5
  • 38
  • 52
22
votes
2 answers

How to rollback an update in PostgreSQL

While editing some records in my PostgreSQL database using sql in the terminal (in ubuntu lucid), I made a wrong update. Instead of - update mytable set start_time='13:06:00' where id=123; I typed - update mytable set start_time='13:06:00'; So,…
damon
  • 8,127
  • 17
  • 69
  • 114
21
votes
10 answers

How can I rollback an UPDATE query in SQL server 2005?

How can I rollback an UPDATE query in SQL server 2005? I need to do this in SQL, not through code.
Guddu
  • 627
  • 3
  • 13
  • 28
21
votes
7 answers

Is there a difference between commit and rollback in a transaction only having selects?

The in-house application framework we use at my company makes it necessary to put every SQL query into transactions, even though if I know that none of the commands will make changes in the database. At the end of the session, before closing the…
Tamas Czinege
  • 118,853
  • 40
  • 150
  • 176
20
votes
1 answer

Can I use transactions with ALTER TABLE?

I'm a beginner (actually newbie) to SQL transactions, so I may be missing something obvious. I have this SQL code, that I'm trying to run through phpMyAdmin: START TRANSACTION; INSERT INTO `users` VALUES(NULL, 'User A', 'user.a@example.com', '4',…
trejder
  • 17,148
  • 27
  • 124
  • 216
20
votes
1 answer

Strange behaviour with @Transactional(propagation=Propagation.REQUIRES_NEW)

Here is my problem : I'm running a batch on a Java EE/Spring/Hibernate application. This batch calls a method1. This method calls a method2 which can throw UserException (a class extending RuntimeException). Here is how it looks like :…
DessDess
  • 787
  • 1
  • 6
  • 20
20
votes
3 answers

In mercurial, how do I apply a reverse-patch to a particular file?

Related to Mercurial: Merging one file between branches in one repo , I'm trying to perform a backout operation on a single file, even though that file was one of many participants in the revision being backed out. HG being the changeset-oriented…
djsadinoff
  • 5,519
  • 6
  • 33
  • 40
19
votes
6 answers

laravel seed rollback after seeding database

I have seeded my DB using php artisan db::seed. Is there a way to rollback what I have seeded into my DB? I cannot seem to find any command like php artisan db::seed rollback.
Aaron
  • 4,380
  • 19
  • 85
  • 141
19
votes
1 answer

Bug in SQLAlchemy Rollback after DB Exception?

My SQLAlchemy application (running on top of MariaDB) includes two models MyModelA and MyModelB where the latter is a child-record of the former: class MyModelA(db.Model): a_id = db.Column(db.Integer, nullable=False, primary_key=True) …
Saqib Ali
  • 11,931
  • 41
  • 133
  • 272
19
votes
4 answers

Is rollback needed if java.sql.Connection#commit() throws exception?

According to JAVA documentation, Connection#commit() can throw SQLException. My question is whether or not a rollback should still be issued in this scenario. For example: Connection con = null; try { // assume this method returns an opened…
dcp
  • 54,410
  • 22
  • 144
  • 164