更新 Mysql 数据库的最快方法
只是想知道更新整个(大型)数据库的最佳方法是什么。
基本上,我继承了一个存在字符问题的数据库,在一些帮助下,我已经对未来的字符问题进行了排序(正在写入),但是现有数据需要清理。
有一个很好的建议,我可以使用 utf_decode 来清理所有这些 - 我已经在页面本身的错误值上尝试过这个(当拉入时),并且效果很好。
由于似乎有很多表和大量数据,使用 utf_decode 扫描整个数据库中的所有数据的最佳/最快方法是什么?
感谢
感谢您的评论,我似乎无法直接发表评论,因此将其作为消息放在这里 - 我会仔细查看并尝试一下!谢谢。
Just wondering what the best way to update an entire (large) database would be.
Bascially I have inherited a DB which had character issues, with some help I have sorted the character issues going forward (being written in) however the existing data needs cleaning up.
There was a good suggestion that I could use utf_decode to clean all this up - I have tried this on a wrong value in the page itself (when pulled in) and it works great.
As there seems to be a lot of tables, and alot of data, what's the best / quickest way to sweep all the data in the entire DB by using utf_decode ?
Thanks
Thanks for the comments, I can't seem to comment directly so dropping as message in here - I will have a look through and give them a go ! thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你尝试过使用 MySQL 函数 CONVERT 吗?根据您的数据,您也许能够在单个语句中更新表,例如“UPDATE mytable SET myfield = CONVERT(myfield USING utf8)”。
http://dev.mysql.com/doc/refman/5.0 /en/charset-convert.html
Have you tried using the MySQL function CONVERT? Depending on your data, you may be able to update tables in a single statement, such as "UPDATE mytable SET myfield = CONVERT(myfield USING utf8)".
http://dev.mysql.com/doc/refman/5.0/en/charset-convert.html
获取所有数据,将其转换并将其插入为:
等等。
比使用多个 INSERT 查询执行 php 循环更快。
编辑:
如果您使用一个好的数组,您可以运行一个流畅的系统来执行此操作:
告诉我您是否需要更多代码示例。
Fetch all the data, convert it and insert it as:
etc.
Goes faster then to do a php loop with multi INSERT queries.
EDIT:
If you use a nice array, you could run a smooth system to do this:
Tell me if you need more code example.