MySQL MariaDB

SQL Uppercase Function

Strings are a universal data type and are most common when working with databases. Therefore, one of the operations you will find yourself carrying out while working with databases is converting them to uppercase.

This article will discuss converting a string to uppercase using Standard SQL. Keep in mind that different database engines may implement custom methods and functions.

SQL Upper

We use the UPPER method to convert a string to uppercase in standard SQL. The function takes a string as the argument and returns the original string with all the alphabetic characters in uppercasing.

The conversion of a string from lowercase to uppercase is determined by the UCD values, as shown in the resource below:

The function syntax is shown below:

UPPER(string);

If no value is provided, the function returns null.

An example of string uppercase conversion is as shown:

select upper('linuxhint');

The previous query should return, as seen below:

    upper
--------------------------
LINUXHINT
(1 row)

If you have a table, you can convert the values of a column to uppercase using the upper method.

Take an example table, as shown below:

To return the result set of the first_name as uppercase, use the following:

select upper(first_name) from table_name;

SQL Lower

The opposite of the upper function is lower function. This function takes a string and returns all the alphabetic characters in lowercase.

Example:

SELECT LOWER('LINUXHINT');

This should return the previous string in lowercase.

Conclusion

In this tutorial, we discussed how to convert a string to uppercase using the Standard SQL function, upper. We hope you found this article helpful. Check out other Linx Hint articles for more tips and tutorials.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list