Jump to content

Locking a whole database while running queries


calabiyau

Recommended Posts

Is there a way to do this?  I need to run a cron job that transfers database information from one database to another and it is very important that the primary keys don't get messed up.  I know you can lock a table but is there a way to lock a whole database while running a long series of queries that go back and forth between multiple tables?

Okay I finally discovered GET_LOCK('$mydtb.mylock',10)

 

I've been testing it at home, by running the script with the lock in it but not releasing the lock.  Then I used a second script to try to access the same database and I am able to.  Would the lock not stay in effect?  Or does it end when the script ends?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.