Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lock

Status
Not open for further replies.

kv444

Programmer
Nov 20, 2011
23
US
Hi,

How do i lock table in oracle, i tried LOCK TABLE Table_name IN EXCLUSIVE MODE and 3 other modes but still i was able to insert data in to the table. I want to lock the table so that the table would reject any data that is being inserted or updated in to this table.



Thanks
 
Locking the table in exclusive mode should have prevented other sessions from updating the table for the duration of the transaction that's holding the lock, but doesn't prevent updates from the session that created the lock. If that's your intent - to prevent yourself from accidentally updating the table while running a query, you should try using "SET TRANSACTION" to create a read-only transaction. An example of doing this can be found in the Oracle documentation, for example

 
Thanks for the reply.

I am trying to lock the whole table,not allow any transcation to the table what so ever. Will SET TRANSACTION work?


Thanks
 
Hi,
do you try to make the table read only? The syntax for this is:
Code:
ALTER TABLE table_name READ ONLY;
Its a new feature in 11g and will prevent the owner from updating/inserting too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top