SQL single-row functions in Oracle databases-continued character Functions
I practiced some character functions in the previous blog, and then I went to the next blog to read the relevant materials.
The character function has not been practiced yet. This time, we mainly perform some supplementary exercises on some unused character functions.
Ascii ()
Returns the decimal number corresponding to the specified character. If it is a string, the decimal number of the first letter of the string is returned. [SQL] select ascii ('aaa') A, ascii ('aaa') a, ascii ('0') ZERO,
Ascii ('') space from dual;
Chr ()
Opposite to ascii functions, given integers return specific characters [SQL] select chr (65) x, chr (97) y from dual;
Instr (C1, C2, I, J)
Searches for a specified character in a string, returns the location of the specified character, and only searches once.
C1: string to be searched
C2: string to be searched
I: the start position of the search. The default value is 1. If the result is positive, the search starts from left to right. 0 does not search
J: the location where it appears: tips: the number of times it appears. The default value is 1. If it is negative or 0, the system reports an error,
Example: [SQL] select instr ('oracle hello Oracle hello', 'oracle ',-1, 2) from dual;
Ltrim, rtrim [SQL] select RTRIM ('Hello oracle ', 'oracle') from dual; -- result: hello: delete 'oracle 'on the right'
Soundex
An interesting function returns a string with the same pronunciation as a given string [SQL] create table test_soundex
(
Username varchar2 (20)
);
Insert into test_soundex values ('kiritor ');
Insert into test_soundex values ('kiito ');
Insert into test_soundex values ('kiritor ');
Insert into test_soundex values ('Alex ');
Select username from test_soundex where soundex (username) = soundex ('kiritor ');
There is a TRIM function in the string processing function. The author will find a detailed understanding and practice of the time.