1

I am using SQL Developer with a IBM DB2 database. I am only querying the data for analytical purposes - never making any updates, additions or deletions. I was wondering if there is a way to ensure that every query is an uncommitted read by default so that I never lock the tables. Is there a way that I can do this without typing FOR FETCH ONLY WITH UR at the end of every query? Would enabling the settings for Autocommit in Preferences -> Database -> Advanced achieve the same goal (not lock tables)?

2

There are a couple of ways to achieve this. Firstly, you can simply run the statement

SET CURRENT ISOLATION UR

in your session before executing other statements.

Alternatively, you can set a property in the JDBC URL you use to connect to the database, like so:

jdbc:db2://host:port/database:defaultIsolationLevel=1;

The value 1 corresponds to the constant java.sql.Connection.TRANSACTION_READ_UNCOMMITTED (note that it is implementation-dependent and may break).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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