Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NO lock in mysql [duplicate]

Tags:

mysql

I am building a desktop application with back-end in MySQL. Does Mysql Support No Lock or some thing equivalent to this as in sql?

Select * from Tablename (NoLock);

Suppose I am fetching data from multiple tables using join, Then do i Need to implement this code while selecting rows from each and every table?

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;
SELECT * FROM 'Table1' 
 iNNERjOIN TABLE2 ON TABLE2.FK=TABLE1.PK ;
COMMIT ;
like image 204
Shashank Avatar asked Jun 03 '13 05:06

Shashank


People also ask

What is with no lock in MySQL?

The WITH (NOLOCK) table hint is used to override the default transaction isolation level of the table or the tables within the view in a specific query, by allowing the user to retrieve the data without being affected by the locks, on the requested data, due to another process that is changing it.

Does MySQL SELECT lock table?

MySQL uses table locking (instead of row locking or column locking) on all table types, except InnoDB and BDB tables, to achieve a very high lock speed.

What causes MySQL locks?

The most common reason implicit locks are created is an INSERT operation: successfully inserted rows are not visible to other transactions until the inserting transaction commits, and it is a common situation that a single transaction inserts many rows, so it is cheaper to not create explicit locks for newly inserted ...


1 Answers

try this

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;
SELECT * FROM Tablename ;
COMMIT ;
like image 92
PSR Avatar answered Sep 19 '22 10:09

PSR