Oracle trim does not drop white space characters

Source: Internet
Author: User

Oracle trim does not drop white space characters

Problem Background:
A business registration number is a normal problem that trim can solve, but in this case, trim is different from what we see with the naked eye, that is, there is an extra character.
Analyze the problem:
In order to reproduce the problem, the following simulation creates a 12345 plus a special character (hypothetical blank)
Select concat ('20140901', chr (9) as xx from dual)
 
 
 
1. Check the length.
SELECT length (concat ('20140901', chr (9) as xx from dual

 

I felt free characters in the above section (6! = 7)
 
Try trim.
SELECT length (xx), length (trim (xx ))
From (
Select concat ('20140901', chr (9) as xx from dual)
 
It is found that trim cannot be dropped or the length is 7.
 
OK. We use the dump function to learn about the data type storage method of oracle.
Select dump (xx) from (select concat ('20140901', chr (9) as xx from dual)


 
The above type = 1 indicates that the value type is VARCHAR2.
Len indicates the number of bytes occupied by the value, which is 7 bytes long.
49,50, 51,52, 53,54, 9
49,50, 51,52, 53,54 for an ascii code of 123456
The ascii value of 9 is a horizontal positioning symbol.
 
But how did this 9 get in? Ctrl + tab!

Solve the problem: update it directly.

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.