Finding and removing non ascii characters from an Oracle Varchar2

前端 未结 17 2225
猫巷女王i
猫巷女王i 2020-12-02 23:03

We are currently migrating one of our oracle databases to UTF8 and we have found a few records that are near the 4000 byte varchar limit. When we try and migrate these reco

17条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 23:55

    If you use the ASCIISTR function to convert the Unicode to literals of the form \nnnn, you can then use REGEXP_REPLACE to strip those literals out, like so...

    UPDATE table SET field = REGEXP_REPLACE(ASCIISTR(field), '\\[[:xdigit:]]{4}', '')
    

    ...where field and table are your field and table names respectively.

提交回复
热议问题