Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

commit after select

I have read the explanations when a commit may be neccessary after a select statement for DB2 and MySQL:

Is a commit needed on a select query in DB2?

Should I commit after a single select

My question is when and why would it be important to commit after executing a select statement using Oracle?

like image 498
Alex Avatar asked Jan 20 '13 23:01

Alex


People also ask

Do you need to commit after a SELECT?

If you are in read committed, single database instance, you don't really need to commit or rollback. If you are in serializable (or read only), single database instance, you need to commit when you would like to be able to see newly committed data from other sessions.

How do you commit changes in SQL?

The COMMIT command saves all the transactions to the database since the last COMMIT or ROLLBACK command. The syntax for the COMMIT command is as follows. Following is an example which would delete those records from the table which have age = 25 and then COMMIT the changes in the database.

What does commit () do in SQL?

A COMMIT statement in SQL ends a transaction within a relational database management system (RDBMS) and makes all changes visible to other users. The general format is to issue a BEGIN WORK statement, one or more SQL statements, and then the COMMIT statement.


1 Answers

there are only a few situations that I can think of that you may want to commit after a select.

  1. if your select is joining on database links, a transaction will be created. if you attempt to close this link, you'd get an error unless you committed/rolled back the transaction.

  2. select for update (as DCookie says) to release the locks.

  3. to remove an serialized isolation level if set or to add one, if you've been selecting from db links prior to invoking this.

like image 52
DazzaL Avatar answered Sep 28 '22 09:09

DazzaL