MySQL的RENAME TABLE陈述如何运作/执行? [英] How does MySQL's RENAME TABLE statment work/perform?

查看:196
本文介绍了MySQL的RENAME TABLE陈述如何运作/执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MySQL具有RENAME TABLE状态,可让您更改表的名称.

MySQL has a RENAME TABLE statemnt that will allow you to change the name of a table.

手册中提到

重命名操作是原子完成的,这意味着没有其他会话可以 重命名运行时访问任何表

The rename operation is done atomically, which means that no other session can access any of the tables while the rename is running

该手册(据我所知)没有说明重命名是如何完成的.是否创建了表的整个副本,并为其指定了新名称,然后又删除了旧表?还是MySQL在后台做一些魔术来快速重命名表?

The manual does not (to my knowedge) state how this renaming is accomplished. Is an entire copy of the table created, given a new name, and then the old table deleted? Or does MySQL do some magic behind the scenes to quickly rename the table?

换句话说,表的大小是否会对RENAME表语句运行多长时间有影响.还有其他可能导致重命名的块显着阻塞的情况吗?

In other words, does the size of the table have an effect on how long the RENAME table statement will take to run. Are there other things that might cause the renaming of a block to significantly block?

推荐答案

我相信MySQL只需更改存储过程中的元数据和对表旧名称的引用-表中的记录数应该无关.

I believe MySQL only needs to alter metadata and references to the table's old name in stored procedures -- the number of records in the table should be irrelevant.

这篇关于MySQL的RENAME TABLE陈述如何运作/执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆