Metadata Locking Begin with two tables  x  and  x_new  that have identical structure. Three clients issue statements that involve these tables: Client 1: LOCK TABLE x WRITE, x_new WRITE; The statement requests and acquires write locks in name order on  x  and  x_new . Client 2: INSERT INTO x VALUES(1); The statement requests and blocks waiting for a write lock on  x . Client 3: RENAME TABLE x TO x_old, x_new TO x; The statement requests exclusive locks in name order on  x ,  x_new , and  x_old , but blocks waiting for the lock on  x . Client 1: UNLOCK TABLES; The statement releases the write locks on  x  and  x_new . The exclusive lock request for  x  by Client 3 has higher priority than the write lock request by Client 2, so Client 3 acquires its lock on  x , then also on  x_new and  x_old , performs the renaming, and releases its locks. Client 2 then acquires its lock on  x , performs the insert, and releases its lock. Lock acquisition order results in the  RENAME TABLE  executing before the  INSERT . The  x  into which the insert occurs is the table that was named  x_new  when Client 2 issued the insert and was renamed to  x  by Client 3: Now begin instead with tables named  x  and  new_x  that have identical structure. Again, three clients issue statements that involve these tables: Client 1: LOCK TABLE x WRITE, new_x WRITE; The statement requests and acquires write locks in name order on  new_x  and  x . Client 2: INSERT INTO x VALUES(1); The statement requests and blocks waiting for a write lock on  x . 1828 mysql>  SELECT * FROM x; +------+ | i | +------+ | 1 | +------+ mysql>  SELECT * FROM x_old; Empty set (0.01 sec)