重命名100GB表
我的数据库中有超过 100GB 大小的表,我想重命名表名称。这是个好主意吗?
I have more than 100GB size of table in my database I want to rename the table name. Is it a good idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
根本不是问题!如果您要更改列,则会出现问题。确保没有人提及旧名称。
Is not a problem at all! Problem if you would change a column. Make sure nobody refers to the old name.
取决于你的mysql版本。版本 5.1 和 5.5 可以通过更改 .frm 文件并重命名该文件来进行重命名。我不确定早期版本。请小心其他 alter table 命令,因为它可能需要创建表数据的副本。
编辑:这也取决于 MySQL 存储引擎。 MyISAM和InnoDB表可以通过更改元数据(即重命名文件)来重命名。但是有一些存储引擎将执行复制操作来执行像表重命名这样简单的操作。
Depends upon your version of mysql. Version 5.1 and 5.5 can do a rename by altering the .frm file and renaming the file. I'm not sure about earlier versions. Be careful of other alter table commands because it may need to create a copy of the table data.
Edit: This is also dependent upon the MySQL storage engine as well. MyISAM and InnoDB tables can be renamed by changing the metadata (i.e renaming the file). But there are some storage engines which will perform the copy operation to do something as simple as a table rename.
是的。大小和名称之间没有依赖性。如果您不必更改代码或存储过程中的查询,那么就可以开始了。
Yes. There is no dependency between the size and the name. If you don't have to change the queries in your code or stored procedures, you are good to go.
在更改了几个表名称以遵循当前命名标准后,我们发现了一个遗留程序,该程序对表名称进行了硬编码,并且必须将所有内容更改回来。为了符合正在构建的新应用程序的命名标准,我们使用当前的命名标准为每个有问题的表创建了一个视图。
After changing several table names to follow the current naming standards we found a legacy program which had the table name hard coded and had to change everything back. To comply with the naming standard for the new app being build we created a view for each offending table with the current naming standard.
理想情况下,它永远不应该产生问题。表的名称不应与同一个表的内容有任何依赖关系。除非您试图弄乱系统表,否则结果不会很好。
Ideally, it should never ever create a problem. The name of the table should not have any dependencies on what the contents of the same table are. Unless you are trying to mess with system tables, in which case the results are not going to be pretty.