Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've a mysql sql locking some tables with different permission (read or write). I've to adapt it for oracle, but I did't found any clear documentation to do this job right.

this is an example:

alpha  read, 
beta write, 
beta as tb read, 
gamma write,
delta read

Any help?

share|improve this question
up vote 2 down vote accepted

Why do you need to lock these tables? What is the problem you are trying to solve?

In Oracle, it is exceptionally rare that you actually need to acquire an explicit lock on a table. And in Oracle, it is impossible to lock a table in a way that prevents other sessions from reading the data in the table. It does not appear that you'll be able to map this directly into Oracle because you cannot block readers.

The lock table syntax in Oracle is relatively similar to the syntax in MySQL. You could, for example

LOCK TABLE alpha IN row exclusive mode;

But it is not clear whether this is going to really solve whatever problem you're facing.

share|improve this answer
I'm porting a web application using mysql to oracle. – Ivan Buttinoni Aug 8 '11 at 10:10
It's clear to me that this massive use of lock it's insane, but I've to in order to replicate the logic used since now. – Ivan Buttinoni Aug 8 '11 at 10:21
An important follow up. In MySql, once you start a lock statement, you must lock every table you query/modify before the release of the lock. That's explain the huge lock statement I write in the example. – Ivan Buttinoni Aug 8 '11 at 13:32
@Ivan - Note that some of this logic simply cannot be replicated in Oracle. As I said in my reply, it is impossible in Oracle to lock a table in a way that prevents other sessions from reading the data in that table. If your application depends on blocking readers, you need to fundamentally reconsider your locking scheme in Oracle. – Justin Cave Aug 8 '11 at 14:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.