如何从数据库中删除十六进制字符?

发布于 2024-09-07 22:29:25 字数 94 浏览 1 评论 0原文

我有一个 MySQL 数据库,其中行包含 %20、%2C 等字符... 如何在不编辑记事本上的文件的情况下从数据库中删除它们? .sql 文件大小约为 300mb... 谢谢

i have a MySQL DB where the rows have characters like %20, %2C, etc...
how can i remove them from the DB without editing the file on notepad?
The .sql file is about 300mb in size...
thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

金橙橙 2024-09-14 22:29:25

什么数据库?

您想用正确的字符替换代码吗?就像 %20 加上“ ”(空格)?

您可能需要准确查看文本是如何转义的,但是您可以使用内置字符串函数天真地执行某些操作:

http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_replace

http://dev.mysql.com/doc/refman/5.1/en/string-functions .html#function_unhex

UPDATE tbl
SET col = REPLACE(col, '%20', UNHEX('20'))
WHERE col LIKE '%\%20%';

另外,我会采取措施确保此类数据不会以任何插入/导入机制进入数据库。

What database?

Do you want to replace codes with their proper characters; like %20 with ' ' (space)?

You may need to look at exactly how your text is escaped, but you can naively do something using builtin string functions:

http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_replace

http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_unhex

UPDATE tbl
SET col = REPLACE(col, '%20', UNHEX('20'))
WHERE col LIKE '%\%20%';

Also, I would take measures to ensure that this kind of data does not get into the database in whatever insert/import mechanism was used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文