INITCAP() function converts the first letter of each word to uppercase and other letters to lowercase.
By definition, words are sequences of alphanumeric characters delimited by a space or any other non-alphanumeric letter.
The following illustrates the syntax of the
INITCAP() function takes one argument:
is the string that should be converted to the proper case
INITCAP() function returns a string in proper case or title case.
The following statement uses the
INITCAP() function to convert a string to proper case:
SELECT INITCAP( 'hi john' ) FROM DUAL;
The result is as follows:
We often use the
INITCAP() function to fix the data e.g., name, email, etc. that has all caps or has mixed case.
See the following
contacts table in the sample database.
The following statement selects the first name and last name from the
contacts table. In addition, it constructs the full name and converts them to the proper case using the
SELECT INITCAP( first_name || ' ' || last_name ) full_name FROM contacts ORDER BY full_name;
The following picture illustrates the result.
In this tutorial, you have learned how to use the Oracle
INITCAP() function to convert a string to proper case.