Convert Column to Title Case or Proper Case in PostgreSQL – INITCAP()

To Convert column to title case in PostgreSQL we will be using  INITCAP() function. It’s a built-in string function which converts a string to title case or proper case. INITCAP() function capitalizes the first letter of each word in a string and converts the rest of the letters to lowercase.

  • Convert string to title case using INITCAP() function
  • Convert column to title case in the PostgreSQL table using INITCAP () function

 

String to title case using INITCAP () Function:

The INITCAP() function in PostgreSQL converts all characters in a string to Title case or proper case.

Example:

 

SELECT INITCAP('address review')

OR

 

SELECT INITCAP('ADDRESS REVIEW')

Output:

Convert Column to Title Case or Proper Case in PostgreSQL - INITCAP() 1

 

 

Convert column to title case or proper case in the PostgreSQL table using INITCAP() function:

INITCAP() function capitalizes the first letter of each word in a string and converts the rest of the letters to lowercase. We will be using the INITCAP() function with select statement to convert the column to proper case

We will be using Employee1 table.

Convert Column to Title Case or Proper Case in PostgreSQL - INITCAP() 2

 

SELECT *, INITCAP(full_name) AS full_name_Titlecase FROM employee1;

In the above example we are converting column “full_name” into proper case or title case with the help of INITCAP() function.

Output:

Convert Column to Title Case or Proper Case in PostgreSQL - INITCAP() 3

 

 

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.

    View all posts