Selecting without Locking the table

suggest change

Sometimes when tables are used mostly (or only) for reads, indexing does not help anymore and every little bit counts, one might use selects without LOCK to improve performance.

SQL Server

SELECT * FROM TableName WITH (nolock)

MySQL

SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM TableName;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;

Oracle

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM TableName;

DB2

SELECT * FROM TableName WITH UR;

where UR stands for “uncommitted read”.


If used on table that has record modifications going on might have unpredictable results.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


SELECT:
*Selecting without Locking the table

Table Of Contents