0
0
PostgreSQLquery~10 mins

UPPER, LOWER, INITCAP in PostgreSQL - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - UPPER, LOWER, INITCAP
Input String
UPPER
Convert to Uppercase
Convert to Lowercase
Capitalize First Letter of Each Word
Return Result
The input string is passed to one of the three functions: UPPER converts all letters to uppercase, LOWER converts all letters to lowercase, and INITCAP capitalizes the first letter of each word.
Execution Sample
PostgreSQL
SELECT UPPER('Hello World');
SELECT LOWER('Hello World');
SELECT INITCAP('HELLO WORLD');
This code converts the string 'Hello World' to uppercase, lowercase, and capitalizes the first letter of each word respectively.
Execution Table
StepFunctionInputOperationOutput
1UPPER'Hello World'Convert all letters to uppercase'HELLO WORLD'
2LOWER'Hello World'Convert all letters to lowercase'hello world'
3INITCAP'HELLO WORLD'Capitalize first letter of each word'Hello World'
4END--Execution complete
💡 All functions processed input strings and returned transformed strings.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
input_string'Hello World''Hello World''Hello World''HELLO WORLD''HELLO WORLD'
resultNULL'HELLO WORLD''hello world''Hello World''Hello World'
Key Moments - 2 Insights
Why does INITCAP change 'hello world' to 'Hello World' and 'HELLO WORLD' to 'Hello World'?
INITCAP capitalizes the first letter of each word and makes the rest lowercase. If input is already uppercase, it will convert the rest to lowercase as shown in step 3 of execution_table.
Does UPPER change non-letter characters like spaces or punctuation?
No, UPPER only changes letters to uppercase. Spaces and punctuation remain unchanged, as seen in step 1 where spaces remain spaces.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the output of LOWER at step 2?
A'HELLO WORLD'
B'Hello World'
C'hello world'
D'hELLO wORLD'
💡 Hint
Check the 'Output' column for step 2 in execution_table.
At which step does the input string change to have each word's first letter capitalized?
AStep 1
BStep 3
CStep 2
DStep 4
💡 Hint
Look at the 'Operation' column describing INITCAP in execution_table.
If the input to UPPER was 'good Morning!', what would be the output?
A'GOOD MORNING!'
B'good morning!'
C'Good Morning!'
D'GOOD morning!'
💡 Hint
Recall UPPER converts all letters to uppercase, non-letters stay the same.
Concept Snapshot
UPPER(text) returns text in all uppercase letters.
LOWER(text) returns text in all lowercase letters.
INITCAP(text) capitalizes the first letter of each word and lowercases the rest.
Non-letter characters remain unchanged.
Useful for formatting text consistently.
Full Transcript
This lesson shows how PostgreSQL string functions UPPER, LOWER, and INITCAP transform text. UPPER converts all letters to uppercase, LOWER converts all letters to lowercase, and INITCAP capitalizes the first letter of each word while making other letters lowercase. The execution table traces each function's input, operation, and output step by step. The variable tracker shows how the input string and result change after each function call. Key moments clarify common confusions about how INITCAP handles letter casing and how non-letter characters are unaffected. The visual quiz tests understanding by referencing the execution table and variable tracker. The concept snapshot summarizes the syntax and behavior of these functions for quick reference.