UCASE Function in SQL
This string function shows all the string characters in the upper case in Structured Query Language. It converts the small character or set of small characters into capital letters.
Syntax of UCASE String Function
Syntax1: This syntax uses the UCASE function with the column name of the SQL table:
In this syntax, Column_Name is the name of that column whose values are to be shown in the upper case.
Syntax2: This syntax uses the UCASE function with the set of lower case characters (string):
Syntax2: This syntax uses the UCASE function with the individual lower case character:
Examples of UCASE String function
Example 1: The following SELECT query converts all the characters of the following string in Upper case (ucase):
Output:
TUTORASPIRE IS A GOOD WEBSITE
Example 2: The following SELECT query cannot change the characters of the following string because the UCASE function cannot change the symbols and integers of the string in SQL.
Output:
Example 3: The following SELECT query converts the small letters into capital letters:
Output:
NEW DELHI IS THE CAPITAL OF INDIA
Example 4: The following SELECT query shows the character ‘s’ in UCASE-case in the output:
Output:
S
Example 5: This example uses the UCASE function with the SQL table
In this example, we are going to create a new table, which is used with the UCASE string function.
The syntax for creating the new table in the SQL database is as follows:
The following CREATE statement creates the Faculty_Info table:
The below INSERT queries insert the records of college Faculties in the Faculty_Info table:
The following SELECT statement displays the inserted records of the above Faculty_Info table:
Faculty_Id | Faculty_First_Name | Faculty_Last_Name | Faculty_Dept_Id | Faculty_Address | Faculty_City | Faculty_Salary |
---|---|---|---|---|---|---|
1001 | ARUSH | SHARMA | 4001 | AMAN VIHAR | DELHI | 20000 |
1002 | BULBUL | ROY | 4002 | NIRMAN VIHAR | DELHI | 38000 |
1004 | SAURABH | ROY | 4001 | SECTOR 128 | MUMBAI | 45000 |
1005 | SHIVANI | SINGHANIA | 4001 | VIVEK VIHAR | KOLKATA | 42000 |
1006 | AVINASH | SHARMA | 4002 | SARVODYA CALONY | DELHI | 28000 |
1007 | SHYAM | BESAS | 4003 | KRISHNA NAGAR | LUCKNOW | 35000 |
The following SELECT query uses the UCASE function with the Faculty_Last_Name column of the above Faculty_Info table:
This SQL statement converts the last name of each faculty in upper case from the above table.
Output:
Faculty_Last_Name | UCASE_LastName |
---|---|
sharma | SHARMA |
roy | ROY |
roy | ROY |
singhania | SINGHANIA |
sharma | SHARMA |
besas | BESAS |
The following SELECT query uses the UCASE function with the Faculty_First_Name, Faculty_City, and Faculty_Address columns of those faculties whose faculty_Id is greater than 1002 in the above Faculty_Info table:
Output:
Faculty_Id | UCASE(Faculty_First_Name) | UCASE(Faculty_Address) | UCASE(Faculty_City) |
---|---|---|---|
1004 | SAURABH | SECTOR 128 | MUMBAI |
1005 | SHIVANI | VIVEK VIHAR | KOLKATA |
1006 | AVINASH | SARVODYA CALONY | DELHI |
1007 | SHYAM | KRISHNA NAGAR | LUCKNOW |
The following SELECT query uses the UCASE function with the Faculty_Last_Name and Faculty_Address columns of those faculties whose faculty_Salary is greater than 30000 in the above Faculty_Info table:
Output:
Faculty_Id | Faculty_Last_Name | Faculty_Dept_Id | Faculty_Address | Faculty_Salary |
---|---|---|---|---|
1002 | roy | 4002 | nirman vihar | 38000 |
1004 | roy | 4001 | sector 128 | 45000 |
1005 | singhania | 4001 | vivek vihar | 42000 |
1007 | besas | 4003 | krishna nagar | 35000 |