开发者

Remove non-ASCII values from Oracle table [duplicate]

开发者 https://www.devze.com 2023-01-08 20:01 出处:网络
This question already has answers here: 开发者_如何学Go Finding and removing Non-ASCII characters from an Oracle Varchar2
This question already has answers here: 开发者_如何学Go Finding and removing Non-ASCII characters from an Oracle Varchar2 (18 answers) Closed 6 years ago.

How can you remove non-ASCII values from a table in Oracle with PL/SQL?


Assuming that you have a table with a VARCHAR2 column that contains some non-alphanumeric characters, then you can replace them with an SQL statement. You might start with something like this and refine it to suit your needs:

UPDATE mytable x
   SET x.col = REGEXP_REPLACE(x.col, '[^[:alnum:] ]', ' ')
 WHERE REGEXP_LIKE (x.col, '.*[^[:alnum:]].*')

This statement uses regular expressions in an attempt to replace all the non-alphanumeric characters with spaces. You will probably need to make adjustments if you want to leave other desired characters, like commas, in place.

Of course, if your needs are massively more complicated than replacing a few characters in a couple of columns then you might need to take a different approach. If this is the case, then perhaps you could expand your question to give more information about your specific problem.

0

精彩评论

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