Lock/unlock a database table

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?


  • Options
    Hi Shyam, You should be able to either commit or rollback to release the lock. Thanks Bhawana
  • Options
    Navin_CNavin_C Vertica Customer
    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.
  • Options
    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

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file