In one of the tables in Oralce, an address field contains full-width characters that need to be converted to half-width characters for further processing.
Table Name: A
Fields that include full-width characters: Address
Edit table structure, add a column: Address2
In Plsql, create a new SQL window, enter: Update a set a.address2 = (To_single_byte (a.address))
Execute, submit, can.
Function Explanation:
Convert to Half-width function:
To_single_byte (s) Conversion perfect angle function: To_multi_byte (s)
Above thisTo_single_byte (s) andTo_multi_byte (s)The premise that a function works is that the database character set consists of single-byte characters and multibyte characters.
My other database is installed with the GBK character set, but looking at the table's inner code, I find that the table's data is stored in the Unicode character set, and I haven't figured out what's going on.
If the database does not contain these characters, you need to replace them manually with the Repalce () function:
Update a t set t.address = replace (t.address, ' a ', ' a ')
Update a t set t.address = replace (t.address, ' B ', ' B ')
Update a t set t.address = replace (t.address, ' C ', ' C ')
Update a t set t.address = replace (t.address, ' d ', ' d ')
Update a t set t.address = replace (t.address, ' e ', ' e ')
Update a t set t.address = replace (t.address, ' f ', ' F ')
Update a t set t.address = replace (t.address, ' g ', ' G ')
Update a t set t.address = replace (t.address, ' h ', ' H ')
Update a t set t.address = replace (t.address, ' I ', ' I ')
Update a t set t.address = replace (t.address, ' J ', ' J ')
Update a t set t.address = replace (t.address, ' k ', ' K ')
Update a t set t.address = replace (t.address, ' l ', ' l ')
Update a t set t.address = replace (t.address, ' m ', ' m ')
Update a t set t.address = replace (t.address, ' n ', ' n ')
Update a t set t.address = replace (t.address, ' o ', ' o ')
Update a t set t.address = replace (t.address, ' P ', ' P ')
Update a t set t.address = replace (t.address, ' Q ', ' Q ')
Update a t set t.address = replace (t.address, ' R ', ' R ')
Update a t set t.address = replace (t.address, ' s ', ' s ')
Update a t set t.address = replace (t.address, ' t ', ' t ')
Update a t set t.address = replace (t.address, ' u ', ' U ')
Update a t set t.address = replace (t.address, ' V ', ' V ')
Update a t set t.address = replace (t.address, ' W ', ' W ')
Update a t set t.address = replace (t.address, ' x ', ' X ')
Update a t set t.address = replace (t.address, ' y ', ' y ')
Update a t set t.address = replace (t.address, ' z ', ' z ')
Update a t set t.address = replace (t.address, '-', '-')
Update a t set t.address = replace (t.address, ' 0 ', ' 0 ')
Update a t set t.address = replace (t.address, ' 1 ', ' 1 ')
Update a t set t.address = replace (t.address, ' 2 ', ' 2 ')
Update a t set t.address = replace (t.address, ' 3 ', ' 3 ')
Update a t set t.address = replace (t.address, ' 4 ', ' 4 ')
Update a t set t.address = replace (t.address, ' 5 ', ' 5 ')
Update a t set t.address = replace (t.address, ' 6 ', ' 6 ')
Update a t set t.address = replace (t.address, ' 7 ', ' 7 ')
Update a t set t.address = replace (t.address, ' 8 ', ' 8 ')
Update a t set t.address = replace (t.address, ' 9 ', ' 9 ')
Manually write these good troubles, there is no way to automate the point.