Reputation: 1980
I have a table with millions of records.
For simplicity let say table is bank and the schema is below,
bank_id int(Primary Key), bank_name varchar, bank_address varchar.
Now if i run a query
update bank set bank_name=NULL where bank_name='null'
My question here is will my query locks the entire table? or only the records that matches the where condition?
Note: I understand as I am querying with non-indexed column the query will take more time and Its a one time execution so I am not worried much about time taken by the query.
Upvotes: 1
Views: 1492
Reputation: 7590
It will lock the entire table.
It locks every row it examines while evaluating the where clause.
Depending on the transaction isolation setting, it may also lock gaps between values, preventing inserts.
Upvotes: 3