➤ Real World RPAD Uses:
-- Format report columns with consistent width:
SELECT RPAD(name, 15, ' ') ||
RPAD(city, 15, ' ') ||
RPAD(dept, 10, ' ') AS report_line
FROM employees;
Output:
Report Line
Raj Delhi Finance
Priya Mumbai IT
Arjun Delhi Finance
• Everything aligned perfectly like a report!
➤ Quick Summary:
• TRIM() = removes spaces or characters from both sides
• TRIM(char FROM string) = removes specific character from both sides
• TRIM LEADING = left side only, TRIM TRAILING = right side only
• LTRIM() = removes characters from LEFT keeps removing while left char is in list
• RTRIM() = removes characters from RIGHT - same logic
• Combine LTRIM RTRIM to remove from both sides for specific chars
• REPLACE(string, find, replace) = replaces ALL occurrences
• REPLACE with empty string = deletes the search string
• LPAD(string, length, char) = pads LEFT to reach total length
• RPAD(string, length, char) = pads RIGHT to reach total length
• If string is longer than total_length - LPAD/RPAD truncate it
#OracleSQL #TRIM #LTRIM #RTRIM #REPLACE #LPAD #RPAD #CharacterFunctions #LearnSQL #Day22 #100DaysOfCode #TechTwitter