Oracle provides the following explanations for ASCII and CHR functions:
ASCII (x) gets the ASCII value of the character X, CHR () and ASCII () have the opposite effect.
That is, the ASCII function is used to convert characters into their corresponding ASCII code, while the CHR function is opposite;
Here are some simple examples:
Select ascii ('x'), ASCII ('y'), ASCII ('Z') from dual;
The statement execution result is 120,121,122 (the ASCII code corresponding to the characters x, y, and z is 120,121,122 ). Then we should easily know the results of select chr ('123'), CHR ('123') from dual.
In the above example, all characters are single characters. What will happen if there are multiple characters? Select ascii ('xy') from dual; the result is 120; select ascii ('x') from dual; the result is 120. We can see from these two examples.
"ASCII gives the ascii value of the first character of a string": the ASCII function only takes effect for the first character in your string;
Finally, we will introduce several common chr () functions, such as chr (9), chr (10), chr (13), chr (32), chr (34 ), here, chr (9) is a tab, chr (10) is a line break, chr (13) is a carriage return, chr (32) is a space character, and chr (34) is a double quotation mark "".
Some people may be confused about the carriage return and line feed, because these two symbols are usually used together. Press enter to return to the beginning of the line, and change the line feed to the next line. Is there a difference between chr (13) and chr (10) in oracle? (There is no difference in the results, because the current language will automatically convert them into "Carriage Return "). That is
Declare
Begin
Dbms_output.put_line ('huiche ');
Dbms_output.put_line (chr (10 ));
Dbms_output.put_line ('hhh ');
End;
Same
Declare
Begin
Dbms_output.put_line ('huiche ');
Dbms_output.put_line (chr (13 ));
Dbms_output.put_line ('hhh ');
End;
The results of two block outputs are exactly the same.