Oracle Plsql Literals

Oracle / PLSQL: Literals

This Oracle tutorial explains how to use literals (text, integer, and number) in Oracle with examples.

Description

In Oracle, a literal is the same as a constant. We'll cover four types of literals - text literals, integer literals, number, and date/time literals.

Text Literals

Text literals are always surrounded by single quotes (').

For example:

'Hewlett Packard'
'28-MAY-03'

Integer Literals

Integer literals can be up to 38 digits. Integer literals can be either positive numbers or negative numbers. If you do not specify a sign, then a positive number is assumed. Here are some examples of valid integer literals:

23
+23
-23

Number Literals

Number literals can be up to 38 digits. Number literals can be either positive or negative numbers. If you do not specify a sign, then a positive number is assumed. Here are some examples of valid number literals:

25
+25
-25
25e-04
25.607

Date/Time Literals

Date and time are enclosed in single quotes (').

For example:

'2015-04-30'
'2015-04-30 08:13:24'

When dealing with date/time values, you will want to use the TO_DATE function to convert a literal to a date.

For example:

SELECT TO_DATE('2015/04/30', 'yyyy/mm/dd')
FROM dual;

This example will take a literal value of '2015/04/30' and convert it to a date.