Thread: Table Locking

  1. No Profile Picture
    Nigel B
    Devshed Newbie (0 - 499 posts)
    I am using a perl script in conjunction with an apache web server to pass queries to a mysql database from html forms.

    Can anyone explain to me when (if at all) I need to use table locking ? I assume that I will need to use locking of some description when tables are being updated, to prevent the situation when several users are simultaneously trying to add rows to tables.

    Also, is there any danger of tables being locked by a script and remaining locked because of some error-type scenario ocurring ?

    I am pretty unclear on the whole area of table locking and would appreciate any guidance which anyone could provide.

  2. #2
  3. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Sure would be nice if somebody replied to this post. I've read a little on table locking, but wouldn't mind hearing from somebody here whose had some experience.


  4. #3
  5. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    The O'Reilly book MySQL/mSQL explains this pretty well. MySQL is mutithreaded, only one thread can write to a table at a time, all other users (threads) are blocked until the first user is done. Now there is a problem if you need to update two or more tables at the same time. You can use the LOCK() function. MySQL will throw an error if you attempt to access an unlocked table while you have other tables locked, so you should lock those you need, use them, then unlock quickly.

Similar Threads

  1. Replies: 2
    Last Post: January 24th, 2004, 10:34 PM
  2. Replies: 3
    Last Post: November 26th, 2003, 08:25 AM
  3. ISAM table locking issues
    By in forum MySQL Help
    Replies: 4
    Last Post: December 20th, 2002, 08:04 PM
  4. help on 3 table join query?
    By smakz in forum Database Management
    Replies: 1
    Last Post: November 19th, 2002, 04:00 AM

IMN logo majestic logo threadwatch logo seochat tools logo