Skip to main content

Lock/unlock a database table


Shyam_Katti
The documentation for locking a database table is not provided in Vertica 5.1.x. When I tried 'LOCK TABLE ', it worked and no other was able to access. Funny, but now I am not able to come up with a command that would unlock the same table :-). I have tried: unlock table and quite few other crazy combinations. Why is this command not specified in the documentation? and how do I unlock the table?

3 replies

Bhawana
Forum|alt.badge.img
  • Participating Frequently
  • July 10, 2013
Hi Shyam, You should be able to either commit or rollback to release the lock. Thanks Bhawana

Navin_C
Forum|alt.badge.img+2
  • Participating Frequently
  • July 10, 2013
Conitnuing the above topic, How does Lock table come in use. I checked it on my end, Locked a table "K" through user a user a can select, insert (read/write) into table "K" at the same time user b can also select /insert (read/write) into table "K" So how does it help or function.

Bhawana
Forum|alt.badge.img
  • Participating Frequently
  • July 11, 2013
Hi Navin, It seems like table "K" is not locked. You can check if that table is locked or not from the following command: select node_names,object_name,lock_mode,lock_scop from LOCKS; Try this one: 1. Open two session at the same time. 2. In session one, run your sql:select * from "table name" for update; 3. In session two, run the same query and it should hang in this session because that table is locked. 4.Back in session one, you should be at vsql prompt - if you type commit, you should then see session 2 return to the vsql prompt(or results first,then vsql) Thanks Bhawana