Oracle 19c SQL

  1. Home
  2. Docs
  3. Oracle 19c SQL
  4. Single Row Character Functions
  5. INITCAP

INITCAP

  • INITCAP is a single row character function.
  • It takes a string and converts first character of each word to upper case and keeps all other letters in lower case.
  • For any input string INITCAP identifies words delimited either by white space or characters that are not alpha-numeric.
  • The return value has the same data type as the argument CHAR type (CHAR or VARCHAR2).

Syntax: INITCAP(Character String)

SELECT
    'the code man' Name,
    INITCAP('the code man') Init_Name
  FROM DUAL;

NAME	     INIT_NAME
------------ ------------
the code man The Code Man
SELECT
    'The Code Man' Name,
    INITCAP('The Code Man') Init_Name
  FROM DUAL;

NAME	     INIT_NAME
------------ ------------
The Code Man The Code Man
SELECT
    'THe CoDE maN' Name,
    INITCAP('THe CoDE maN') Init_Name
  FROM DUAL;

NAME	     INIT_NAME
------------ ------------
THe CoDE maN The Code Man
SELECT
    'THE CODE MAN' Name,
    INITCAP('THE CODE MAN') Init_Name
  FROM DUAL;

NAME	     INIT_NAME
------------ ------------
THE CODE MAN The Code Man
SELECT
    'THECODE man' Name,
    INITCAP('THECODE man') Init_Name
  FROM DUAL;

NAME	    INIT_NAME
----------- -----------
THECODE man Thecode Man

Q: How INITCAP function identifies the different words in a particular string for its operation?

Ans: INITCAP identifies different words for its operation by considering the delimiter as white space or any special characters encountered in the argument string. INITCAP treats all characters as special character except alphanumeric values.

SELECT 
    'info-dcodeman@gmail.com' Actual_Email,
    INITCAP('info-dcodeman@gmail.com') Init_Email
  FROM DUAL;

ACTUAL_EMAIL		    INIT_EMAIL
----------------------- -----------------------
info-dcodeman@gmail.com Info-Dcodeman@Gmail.Com
SELECT 
    'info#the 12dcode_m23an@gma34il.com' Actual_Email,
    INITCAP('info#the dcode_man@gmail.com') Init_Email
  FROM DUAL;

ACTUAL_EMAIL			           INIT_EMAIL
---------------------------------- ----------------------------
info#the 12dcode_m23an@gma34il.com Info#The Dcode_Man@Gmail.Com
SELECT 
    'sample text1for@initcap!demo' Actual_Str,
    INITCAP('sample text1for@initcap!demo') Init_Str
  FROM DUAL;

ACTUAL_STR                   INIT_STR
---------------------------- ----------------------------
sample text1for@initcap!demo Sample Text1for@Initcap!Demo
Was this article helpful to you? Yes No

How can we help?