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 does not implement READ UNCOMMITTED. Its weakest isolation level is READ COMMITTED.

DB2

SELECT * FROM TableName WITH UR;

where UR stands for “uncommitted read”.


A read that allows uncommitted data can return rows that are later rolled back. The SQL Server hint NOLOCK is not portable.

Feedback about page:

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



Table Of Contents