Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql-锁定并刷新特定表的挂起数据_Mysql_Locking_Flush_Unlock - Fatal编程技术网

Mysql-锁定并刷新特定表的挂起数据

Mysql-锁定并刷新特定表的挂起数据,mysql,locking,flush,unlock,Mysql,Locking,Flush,Unlock,我需要临时重命名一个表。此表始终有插入项。因此,我们的想法是锁定表以进行写入和读取,然后刷新所有可能的挂起插入,然后重命名表,做一些事情,重新重命名表并解锁它,使其再次可用 一个人应该采取什么步骤来完成这项或尽可能接近的任务 谢谢 好的,算了 lock tables sometable write; flush tables sometable; unlock tables; rename table `sometable` to `sometable_locked`; -- do someth

我需要临时重命名一个表。此表始终有插入项。因此,我们的想法是锁定表以进行写入和读取,然后刷新所有可能的挂起插入,然后重命名表,做一些事情,重新重命名表并解锁它,使其再次可用

一个人应该采取什么步骤来完成这项或尽可能接近的任务

谢谢

好的,算了

lock tables sometable write;
flush tables sometable;
unlock tables; rename table `sometable` to `sometable_locked`;
-- do something useful
rename table `sometable_locked` to `sometable`;

lock tables sometable write;
flush tables sometable;
alter table `sometable` rename to `sometable_locked`;
-- do something useful
unlock tables; alter table `sometable_locked` rename to `sometable`;