开发者

How to remove hex characters from DB?

开发者 https://www.devze.com 2023-01-05 23:39 出处:网络
i have a MySQL DB where the rows have c开发者_如何学JAVAharacters like %20, %2C, etc... how can i remove them from the DB without editing the file on notepad?

i have a MySQL DB where the rows have c开发者_如何学JAVAharacters 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消