Groups | Blog | Home
all groups > sql server programming > april 2005 >

sql server programming : how to change the default table locking type ?


Sniper
4/17/2005 11:43:01 PM
Hi guys,
Is there anyway to change the default recode locking type (Table
Locking) to row locking !! ?

Thanks in help
Uri Dimant
4/18/2005 12:00:00 AM
Sniper
As far as I know SQL Server begins with a low type (row locking) and
increase if it needs.



[quoted text, click to view]

Itzik Ben-Gan
4/18/2005 12:00:00 AM
Using the sp_indexoption stored procedure you can play with the options:
AllowRowLocks, AllowPageLocks, DisAllowRowLocks, DisAllowPageLocks for each
index.
By default, SQL Server considers the locking granularity automatically, and
the default choices it makes are usually best.

--
BG, SQL Server MVP
www.SolidQualityLearning.com


[quoted text, click to view]

Tibor Karaszi
4/18/2005 12:00:00 AM
In addition to the other posts, supporting the query with good and usable indexes reduces the risk
of getting table locks.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/


[quoted text, click to view]

Sniper
4/18/2005 11:48:02 PM
Hi Tibor,

Thanks for your reply. it's like this, When I do a start transaction and do
a row modification, it locks the hole table, it there anyway to lock only the
modified row ?

Thanks alot for u r time and response,
-Aruna


[quoted text, click to view]
Tibor Karaszi
4/19/2005 12:00:00 AM
Not directly. As I said, make sure that you support the WHERE clauses you use in the UPDATE with
proper indexes and you are most likely to end up with row locks. How did you determine that the
whole table is locked?

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/


[quoted text, click to view]

Tibor Karaszi
4/19/2005 12:00:00 AM
Use sp_who, sp_who2, sp_lock etc to determine what types of locks the connection which has modified
the data has on the table. Also, you still haven't provided us with the table structure and what
indexes you have on the table and what your UPDATE statement look like.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/


[quoted text, click to view]

Tibor Karaszi
4/19/2005 12:00:00 AM
Also, if you have updated some row, and haven't committed that transaction, any process which tries
to read *all* rows will be blocked.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/


[quoted text, click to view]

Sniper
4/19/2005 4:45:02 AM

When I open the table from the Enterprise Manager it doesn't show the table
data. or when I do a SELECT * FROM table it's waitting till the table lock to
be released.

thanks,
Sniper

[quoted text, click to view]
AddThis Social Bookmark Button