DB2 Tutorial

  • Home
  • Start Here
  • Basics
  • Views
  • Triggers
  • Indexes
  • Functions
    • Aggregate Functions
    • Date Functions
    • String Functions
    • Window Functions
Home » Db2 String Functions » Db2 UPPER

Db2 UPPER

Summary: in this tutorial, you will learn how to use the Db2 UPPER() function to convert all characters of a string to uppercase.

DB2 UPPER() function overview

The UPPER() function accepts a string and returns a new string in which all characters in the original string are converted to uppercase.

Here is the syntax of the UPPER() function

UPPER(expression)

In this syntax, the expression must evaluate to a character string or a value that can be implicitly converted to a character string.

The UPPER() function is useful for case-insensitive searches.

Db2 UPPER() function examples

Let’s take some examples of using the UPPER() function.

1) Using Db2 UPPER() to convert a literal string to uppercase.

This example uses the UPPER() function to convert the string 'Db2 upper' to uppercase:

SELECT UPPER('Db2 upper') result FROM sysibm.sysdummy1;

Here is the result set:

RESULT --------- DB2 UPPER

2) Using Db2 UPPER() to perform case insensitive searches

See the following authors table from the sample database:

The following example uses the UPPER() function to search for authors whose last name are Anderson:

SELECT author_id, first_name, last_name FROM authors WHERE UPPER(last_name) = 'ANDERSON';

Here is the output:

Db2 UPPER function example

To speed up this query, you should consider creating an expression-based index for the last_name column:

CREATE INDEX ix_ulastname ON authors(UPPER(last_name));

In this tutorial, you have learned how to use the Db2 UPPER() function to convert all characters of a string to uppercase.

  • Was this tutorial helpful ?
  • YesNo
Previous Db2 INSTR

Getting Started

  • What is Db2
  • Installing Db2 Database Server
  • Db2 Sample Database
  • Creating a Db2 Sample Database
  • Connecting to a Db2 Database
  • Interacting with Db2 using SQL Developer

Data Manipulation

  • SELECT
  • ORDER BY
  • WHERE
  • SELECT DISTINCT
  • AND
  • OR
  • BETWEEN
  • LIKE
  • IN
  • LIMIT
  • FETCH
  • Join
  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • FULL OUTER JOIN
  • Self-Join
  • CROSS JOIN
  • GROUP BY
  • Subquery
  • HAVING
  • UNION
  • INTERSECT
  • EXCEPT
  • Common Table Expression or CTE
  • INSERT
  • INSERT Multiple Rows
  • INSERT INTO SELECT
  • UPDATE
  • DELETE

Managing Database Objects

  • CREATE TABLE
  • Identity Columns
  • ALTER COLUMN
  • ADD COLUMN
  • DROP COLUMN
  • DROP TABLE
  • TRUNCATE TABLE
  • RENAME TABLE

Db2 Constraints

  • Primary Key
  • Foreign Key
  • DEFAULT
  • NOT NULL
  • CHECK
  • UNIQUE

Db2 Data Types

  • Integer
  • Decimal
  • VARCHAR
  • CHAR
  • DATE
  • TIME
  • TIMESTAMP

Useful Functions & Expressions

  • CAST
  • CASE Expression
  • COALESCE

About db2tutorial.com

The db2tutorial.com website provides you with a comprehensive IBM DB2 tutorial with many practical examples and hands-on sessions.

Recent Tutorials

  • Db2 Functions
  • Db2 RANK
  • Db2 ROW_NUMBER
  • Db2 Window Functions
  • What is Db2

Site Links

  • Home
  • About Us
  • Contact Us
  • Privacy Policy
Copyright © © 2021 by www.db2tutorial.com. All Rights Reserved.