The PLSQL SOUNDEX function is used for returning a phonetic representation of a string. The phonetic represents the way the string will sound. The PLSQL SOUNDEX function helps to compare words that are spelled differently, but sound alike in English.
The SOUNDEX function accepts one parameter input_string which can be of any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The return value is the same datatype as char.
Syntax:
SOUNDEX( input_string )
Parameters Used:
input_string – It is used to specify the string whose phonetic representation you want to know.
Note:
- The value returned by the SOUNDEX function will always begin with the first letter of the input_string.
- The SOUNDEX function uses only the first 5 consonants to determine the NUMERIC portion of the return value, except if the first letter of string1 is a vowel.
- The SOUNDEX function is not a case-sensitive function.
Supported Versions of Oracle/PLSQL:
- Oracle 12c
- Oracle 11g
- Oracle 10g
- Oracle 9i
- Oracle 8i
Example-1:
DECLARE
Test_String string(25) := 'geeksforgeeks';
BEGIN
dbms_output.put_line(SOUNDEX(Test_String));
END;
Output:
G216
Example-2:
DECLARE
Test_String string(25) := 'GEEKSFORGEEKS';
BEGIN
dbms_output.put_line(SOUNDEX(Test_String));
END;
Output:
G216
Example-3:
DECLARE
Test_String string(25) := 'Hello';
BEGIN
dbms_output.put_line(SOUNDEX(Test_String));
END;
Output:
H400
Example-4:
DECLARE
Test_String string(25) := 'Hello';
BEGIN
dbms_output.put_line(SOUNDEX(Test_String));
END;
Output:
H400
Example-5:
DECLARE
Test_String string(25) := 'Hello User';
BEGIN
dbms_output.put_line(SOUNDEX(Test_String));
END;
Output:
H426
Unlock the Power of Placement Preparation!
Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our
Complete Interview Preparation Course is the ultimate guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview triumph.
Ready to dive in? Explore our Free Demo Content and join our
Complete Interview Preparation course.
Last Updated :
27 Sep, 2019
Like Article
Save Article