Oracle INITCAP() Function
The Oracle (PL/SQL) INITCAP() function converts the first letter of each word to upper case and the rest to lower case. Words are sequences of alphanumeric characters separated by non-alphanumeric characters. If there are characters in the string that are not letters, they will be unaffected by this function.
Syntax
INITCAP(string)
Parameters
string |
Required. Specify the string to convert. |
Return Value
Returns the string with first letter of each word to upper case and the rest to lower case.
Example 1:
The example below shows the usage of INITCAP() function.
INITCAP('Learning Oracle is FUN!') Result: 'Learning Oracle Is Fun!' INITCAP('Oracle tutorial') Result: 'Oracle Tutorial'
Example 2:
Consider a database table called Employee with the following records:
EmpID | Name | City | Age | Salary |
---|---|---|---|---|
1 | John | london | 25 | 3000 |
2 | Marry | new york | 24 | 2750 |
3 | Jo | paris | 27 | 2800 |
4 | Kim | amsterdam | 30 | 3100 |
5 | Ramesh | new delhi | 28 | 3000 |
6 | Huang | beijing | 28 | 2800 |
The query given below is used to convert the City column values using this function.
SELECT Employee.*, INITCAP(City) AS INITCAP_Value FROM Employee;
The query will produce the following result:
EmpID | Name | City | Age | INITCAP_Value |
---|---|---|---|---|
1 | John | london | 25 | London |
2 | Marry | new york | 24 | New York |
3 | Jo | paris | 27 | Paris |
4 | Kim | amsterdam | 30 | Amsterdam |
5 | Ramesh | new delhi | 28 | New Delhi |
6 | Huang | beijing | 28 | Beijing |
❮ Oracle Functions