在我的出产数据库中,行使“latin”的默认CharSet建设警报相干表,因此我们在实行时碰着错误 在表中插入日语字符.我们必要将表和列的默认字符集变动为UTF8. 因为这些表具有大量数据,因此Alter呼吁也许必要耗费很长时刻(在我的当地数据库中行使沟通数目的数据必要5小时) 并锁定将导致数据丢失的表.我们是否可以打算一种机制来将Charset变动为UTF8,而不会丢失数据.
哪个是变动大型数据表的字符集的更好要领?
最佳谜底
我在mysql手册http://dev.mysql.com/doc/refman/5.1/en/alter-table.html上找到了这个:
In most cases,ALTER TABLE makes a temporary copy of the original
table. MySQL waits for other operations that are modifying the table,
then proceeds. It incorporates the alteration into the copy,deletes
the original table,and renames the new one. While ALTER TABLE is
executing,the original table is readable by other sessions. Updates
and writes to the table that begin after the ALTER TABLE operation
begins are stalled until the new table is ready,then are
automatically redirected to the new table without any failed updates
以是是的 – 在这样做的同时最大限度地镌汰停机时刻是很棘手的.这取决于您的表的行使环境,是否有更多的读/写?
我能想到的一种要领是行使某种复制.因此,建设一个行使UTF-8的新Alert表,并找到一种要领将原始表复制到新表而不影响可用性/吞吐量.复制完成后(或足够靠近),通过重定名切换表?
虽然,这提及来轻易做起来 – 假如也许的话还必要更多的进修.
(编辑:湖南网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|