SQL String Functions (Part 1) | UPPER(), LOWER(), LENGTH(), LEFT(), RIGHT() | CBSE Class 12 Informatics Practices (2026–27)
Class 12 · Informatics Practices
SQL String Functions (Part 1)
String functions are used to manipulate text values stored in a database. These functions help convert letter cases, count characters, and extract specific parts of a string.
In this article, we will learn the following CBSE-prescribed SQL string functions:
- UPPER() / UCASE()
- LOWER() / LCASE()
- LENGTH()
- LEFT()
- RIGHT()
Sample Table
| EmpID | Name | Department |
|---|---|---|
| 101 | Amit Sharma | Sales |
| 102 | Neha Gupta | Finance |
| 103 | Rohan Verma | HR |
1. UPPER() / UCASE()
The UPPER() or UCASE() function converts all characters of a string into uppercase letters.
Syntax
UPPER(column_name) OR UCASE(column_name)
Example
SELECT UPPER(Name) FROM Employee;Output
AMIT SHARMA NEHA GUPTA ROHAN VERMA
2. LOWER() / LCASE()
The LOWER() or LCASE() function converts all characters into lowercase letters.
Syntax
LOWER(column_name) OR LCASE(column_name)
Example
SELECT LOWER(Name) FROM Employee;Output
amit sharma neha gupta rohan verma
3. LENGTH()
The LENGTH() function returns the total number of characters in a string, including spaces.
Syntax
LENGTH(column_name)
Example
SELECT Name,
LENGTH(Name)
FROM Employee;
If the name is "Amit Sharma", the result includes the space between the two words.
4. LEFT()
The LEFT() function returns the specified number of characters from the beginning (left side) of a string.
Syntax
LEFT(string, number_of_characters)
Example
SELECT LEFT(Name,4) FROM Employee;Output
Amit Neha Roha
5. RIGHT()
The RIGHT() function returns the specified number of characters from the end (right side) of a string.
Syntax
RIGHT(string, number_of_characters)
Example
SELECT RIGHT(Name,6) FROM Employee;Output
Sharma Gupta Verma
Comparison of String Functions
| Function | Purpose | Example |
|---|---|---|
| UPPER() | Convert to uppercase | UPPER('amit') |
| LOWER() | Convert to lowercase | LOWER('AMIT') |
| LENGTH() | Count characters | LENGTH('Python') |
| LEFT() | Extract left characters | LEFT('Python',3) |
| RIGHT() | Extract right characters | RIGHT('Python',3) |
Real-Life Applications
| Function | Application |
|---|---|
| UPPER() | Generate reports in uppercase. |
| LOWER() | Standardize email addresses. |
| LENGTH() | Validate passwords or IDs. |
| LEFT() | Extract state or branch codes. |
| RIGHT() | Extract last digits of account numbers. |
Common Errors
| Error | Reason |
|---|---|
| Unknown Column | Incorrect column name. |
| Syntax Error | Missing brackets or commas. |
| Incorrect Arguments | Wrong number of parameters. |
Quick Revision
| Function | Purpose |
|---|---|
| UPPER() | Uppercase |
| LOWER() | Lowercase |
| LENGTH() | Count characters |
| LEFT() | Characters from left |
| RIGHT() | Characters from right |
CBSE Exam Tips
UPPER()andUCASE()perform the same function.LOWER()andLCASE()perform the same function.LENGTH()counts spaces as characters.LEFT()extracts characters from the beginning of a string.RIGHT()extracts characters from the end of a string.
Summary
SQL string functions help manipulate text stored in database tables. Functions such as UPPER(), LOWER(), LENGTH(), LEFT(), and RIGHT() are commonly used for formatting, validating, and extracting text data. These functions are frequently used in CBSE theory questions, practical examinations, and real-world database applications.