问题描述:

Now I am using Sybase, when I create table, I should give a locking schema for it. I know other DB can choose lock by DBMS. Now I have two questions for this:

  1. When I give a all page lock for locking schema to a table, but when I delete rows or insert rows, I check the lock, I find the lock can be row share lock. Otherwise, when I use rows lock for locking schema, it may choose table exclude lock. So what are the locking schema use for?

  2. Can a row lock to implement DB tansaction isloation level 3. I know in this level you can't insert new row which fits for other transaction select results. I want to know can a DBMS only use row lock or page lock to imeplement the isoation level 3.

网友答案:

The locking scheme can be set a couple different ways. A default can be set at the server level, and all tables created will use the default. If the default is changed, the tables will not convert to the new locking scheme automatically, as far as I know.

You typically choose the locking schema based on your needs for the system. Each level of locking granularity has a performance cost, and a concurrency cost, so acquiring a table lock is cheaper than a page level lock, but limits some of the concurrent transactions on the locked table.

The table locking schemes are not directly related to the server isolation level. The isolation level can be set server wide, or per transaction, and may only affect the type of lock acquired by the requesting process. You can have isolation level 3 on tables with any locking scheme. In some ways the isolation level is a logical control, and the locking scheme is a physical control.

I really suggest you read the documentation, as it covers so much more than I can cover here.

Granularity of locks and locking schemes

How isolation levels affect locking

相关阅读:
Top