Oracle table field full-width character conversion Half-width character method __oracle

Source: Internet
Author: User

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.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.