Lock a table in Sybase ASE 15.5

lockingsybase-ase

I would like to lock a table to only allow users to perform read operation in Sybase ASE 15.5, how can I do it? I have tried the below command, but seems there is some confusion. Any idea?

Session A: Perform below commands and after that try to perform insert operation. New records can still insert into locked table (but I think it is not commit the transaction yet). Can still select record from the locked table.

begin transaction
lock table testB in share mode

Session B: Cannot select data from the locked table.

Best Answer

I think you should look at locking mechanism of table, there are three types of them - AllPages, Datapages and Datrows, you can read more about them at:

Locking Mechanism in Sybase

If you alter locking of table, update/delete and select can take place together without any blocking on mentioned table.

Inside query, you can put noholdlock on a table or other options for other users to access/no access based on these options as mentioned in below link:

Controlling Isolation

In order to answer your question in detailed level, we need to have more clarity on question. Your question doesn't explain details of issue. I hope above helps.