How to open exclusive a table in Oracle9i ?

kmthien

Senior member
Oct 8, 2002
363
0
0
Hi guys,

How to open exclusive a table in Oracle9i like in Access, where when user1 is selecting,updating or deleting from this table, other users won't be able to select any data from this table until user1 completing his operation. Pls help....
 

Argo

Lifer
Apr 8, 2000
10,045
0
0
You need to change lock level from row to table. In DB2 it's a database option, rather than table. Oracle might be similar in that.
 

Argo

Lifer
Apr 8, 2000
10,045
0
0
Not sure. Try google, oracle website, documentation that came with the software. Shouldn't be too hard to find.
 

Haircut

Platinum Member
Apr 23, 2000
2,248
0
0
You can use

LOCK TABLE tablename IN EXCLUSIVE MODE;

to lock any given table, this will stop any other user from updating, inserting or deleting from that table until you either rollback or commit the transaction.
 

kmthien

Senior member
Oct 8, 2002
363
0
0
Hi Haircut,

U mean I need to execute LOCK TABLE tablename IN EXCLUSIVE MODE statement first? For example, if I m using OCI in VC++ 6.0, I need to do the following?

COdb ora;
CString sql = "LOCK TABLE TABLE1 IN EXCLUSIVE MODE";
ora.exec(sql);
//This will lock TABLE1 from excessing by others ?
sql = "select * from TABLE1";
ora.Select(sql);
ora.close(); //release the lock ?

Pls help...Thx !

 
Apr 16, 2003
179
0
0
If u explain why you want to lock a table I'm sure I could be more help - I've been coding for a while and have never needed to lock a table (alright - I tell a lie - I have once)