w3resource

SQL UPPER() function

UPPER() function

The SQL UPPER() function is used to convert all characters of a string to uppercase.

Syntax:

 UPPER(string) 

PostgreSQL, MySQL, SQL Server and Oracle

All of above platforms support the SQL syntax of UPPER().

Parameters:

Name Description
string A string.

Visual Presentation:

SQL UPPER() pictorial presentation

Application of UPPER()

In the subsequent pages, we have discussed how to apply UPPER() with various SQL clauses. we have used Oracle 10g Express Edition.

Example:

To get string the 'testing for upper function' in upper case from the DUAL table, the following SQL statement can be used :

SQL Code:


-- This SQL query converts a given string to uppercase using the UPPER function and returns the result with an alias.
-- SELECT statement begins
SELECT 
    UPPER('testing for upper function') -- Convert the given string 'testing for upper function' to uppercase
    AS Testing_Upper -- Alias the result of the uppercase conversion as 'Testing_Upper'
FROM 
    dual; -- Dual is a dummy table in Oracle, used here as a placeholder since we're not actually querying any table

Explanation:

  • This SQL code is a SELECT statement that demonstrates the use of the UPPER function to convert a string to uppercase.
  • The string 'testing for upper function' is passed as an argument to the UPPER function.
  • The result of the conversion is then given an alias 'Testing_Upper'.
  • The query is executed against the 'dual' table, which is a system-generated table in Oracle. It's frequently utilized as a placeholder for scenarios where you need to perform a calculation or expression but don't require data from an actual table.

In the above example 'Testing_Upper' is a column alias which will come as a column heading to the output.

Output:

TESTING_UPPER
--------------------------
TESTING FOR UPPER FUNCTION

See our Model Database

Here is a new document which is a collection of questions with short and simple answers, useful for learning SQL as well as for interviews.

Check out our 1000+ SQL Exercises with solution and explanation to improve your skills.

Previous: LOWER
Next: TRIM



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/sql/character-functions/upper.php