How to Capitalize Each Words' First Letter in PostgreSQL (2024)

Problem:

In a PostgreSQL string, you need to make the first letter of each word uppercase and the rest of the letters lowercase.

Example:

Our database has a table named student with data in two columns, id and full_name.

idfull_name
1ANNE WILLIAMS
2alice brown
3Gary JACKSON

Let’s change the capitalization of students’ full names by converting this string so that only the first letters of the first and last names are capitalized – just as we’d normally write them.

Solution:

We’ll use the INITCAP() function. Here’s the query you’d write:

SELECT INITCAP (full_name) AS new_full_nameFROM student;

Here’s the result:

new_full_name
Anne Williams
Alice Brown
Gary Jackson

Discussion:

In PostgreSQL, you can use the INITCAP() function to convert a string to a new string that capitalizes the first letter of every word. All other letters will be lowercase. This function takes one parameter as a string and changes the capitalization for each word as described.

How to Capitalize Each Words' First Letter in PostgreSQL (1)

In our example, the full name Anne Williams was originally stored in the column full_name as ANNE WILLIAMS; after converting, this full name is Anne Williams.

How to Capitalize Each Words' First Letter in PostgreSQL (2024)

FAQs

How to Capitalize Each Words' First Letter in PostgreSQL? ›

In PostgreSQL, you can use the INITCAP() function to convert a string to a new string that capitalizes the first letter of every word. All other letters will be lowercase. This function takes one parameter as a string and changes the capitalization for each word as described.

How do you capitalize the first letter of each word in SQL? ›

The UCASE function is used to convert the first letter of each word to uppercase, and LCASE is used to convert the rest of the word to lowercase. This is then concatenated together using the CONCAT function.

How do you capitalize the first letter of each word? ›

To use a keyboard shortcut to change between lowercase, UPPERCASE, and Capitalize Each Word, select the text and then press fn+ SHIFT + F3 until the style you want is applied.

How do you uppercase the first letter of each word in MySQL? ›

You can use the UCWORDS() function in MySQL to capitalize the first letter of each word in a column. Here is an example query that demonstrates how to use this function: UPDATE your_table SET your_column = UCWORDS(your_column);

How do you capitalize the first letter of each word in sheets? ›

The Proper Function

The syntax =PROPER(text) requires either a direct string of text or a cell reference as its argument. Effectively, it capitalizes the first letter of every word in a given string, making it useful for formatting titles or headings in your spreadsheet.

How do you capitalize the first letter in PostgreSQL? ›

In PostgreSQL, you can use the INITCAP() function to convert a string to a new string that capitalizes the first letter of every word. All other letters will be lowercase.

How do you capitalize keywords in SQL? ›

No, SQL is not a case-sensitive language, so it doesn't matter if you use upper case or lower case for SQL commands. However, it's recommended to use a consistent capitalization style for better code readability and maintainability.

Which function will you use to capitalize first letter of each word? ›

Method 1: Using charAt(), toUpperCase(), and slice()

Explanation: This function takes a string as an argument and capitalizes its first letter. It does this by using charAt(0) to access the first character of the string and toUpperCase() to convert this character to uppercase.

Can you capitalize the first letter? ›

This is a stable rule in our written language: Whenever you begin a sentence capitalize the first letter of the first word. This includes capitalizing the first word or a direct quotation when it's a full sentence, even if it appears within another sentence. Her daughter loved the valentine.

When you capitalize the first letter of each word with no spaces? ›

Camel case (sometimes stylized autologically as camelCase or CamelCase, also known as camel caps or more formally as medial capitals) is the practice of writing phrases without spaces or punctuation and with capitalized words.

How to capitalize first letter of each word in Oracle SQL? ›

INITCAP returns char , with the first letter of each word in uppercase, all other letters in lowercase. Words are delimited by white space or characters that are not alphanumeric.

How do you get the first character of each word in a string in SQL? ›

we sometimes categorize the data based on the first character of the string. To get the first character from a string, we can use the SUBSTRING() function or SUBSTR() function.

How do you check if the first letter of a string is uppercase? ›

We'll need to use the isUpperCase method from the Ascii class to check if the first letter of a string is uppercase. Then, we'll apply the isUpperCase method to the first letter of our example string: Assertions. assertTrue(Ascii.

How do you capitalize the first letter of each word in a string in CSS? ›

You can use the text-transform CSS property to capitalize text in different forms. This property can modify text to be in uppercase, lowercase, or capitalized (so that each word begins with a capital letter and the remaining characters in the word retain their original form).

Is there a way to capitalize the first letter of every word in Excel? ›

Step 1: Type the individual names in Excel. Step 2: The cell to the right of the first name, type in the formula. Example: =PROPER(A2) Step 3: Use the fill handle to copy the formula to the other cells in the spreadsheet. Hint: Make sure all formulas/functions in Excel start with an equals sign.

How do you capital letters in SQL? ›

If you wanted to convert the name column to uppercase, you would use the following query: SELECT UPPER(name) FROM users; This query would return the result JOHN, JANE, JOHN, BOB, since all of the names in the table have been converted to uppercase.

What is the shortcut for capitalize all letters in SQL? ›

  1. Upper Case : ctr + shift + U.
  2. Lower Case : ctr + shift + L.
Jan 26, 2016

Top Articles
Ways to Bank | TD Branch Banking and ATM
Otterscan | Erigon Documentation
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
Things To Do In Atlanta Tomorrow Night
Non Sequitur
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
Selly Medaline
Latest Posts
Article information

Author: Arielle Torp

Last Updated:

Views: 6449

Rating: 4 / 5 (41 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Arielle Torp

Birthday: 1997-09-20

Address: 87313 Erdman Vista, North Dustinborough, WA 37563

Phone: +97216742823598

Job: Central Technology Officer

Hobby: Taekwondo, Macrame, Foreign language learning, Kite flying, Cooking, Skiing, Computer programming

Introduction: My name is Arielle Torp, I am a comfortable, kind, zealous, lovely, jolly, colorful, adventurous person who loves writing and wants to share my knowledge and understanding with you.