PL/SQL - Constants and Literals
PL/SQL - Constants and Literals
In this chapter, we will discuss constants and literals in PL/SQL. A constant holds a value
that once declared, does not change in the program. A constant declaration specifies its
name, data type, and value, and allocates storage for it. The declaration can also impose
the NOT NULL constraint.
Declaring a Constant
A constant is declared using the CONSTANT keyword. It requires an initial value and does
not allow that value to be changed. For example −
When the above code is executed at the SQL prompt, it produces the following result −
https://www.tutorialspoint.com/plsql/plsql_constants.htm 1/4
4/2/2019 PL/SQL - Constants and Literals
Radius: 9.5
Diameter: 19
Circumference: 59.69
Area: 283.53
Numeric Literals
Character Literals
String Literals
BOOLEAN Literals
The following table provides examples from all these categories of literal values.
Numeric Literals
Character Literals
2
'A' '%' '9' ' ' 'z' '('
String Literals
'Hello, world!'
3
'Tutorials Point'
'19-NOV-12'
4 BOOLEAN Literals
https://www.tutorialspoint.com/plsql/plsql_constants.htm 2/4
4/2/2019 PL/SQL - Constants and Literals
5 DATE '1978-12-25';
To embed single quotes within a string literal, place two single quotes next to each other
as shown in the following program −
DECLARE
message varchar2(30):= 'That''s tutorialspoint.com!';
BEGIN
dbms_output.put_line(message);
END;
/
When the above code is executed at the SQL prompt, it produces the following result −
That's tutorialspoint.com!
Advertisements
MAKEMYTRIP.COM
VENTURE PARK
https://www.tutorialspoint.com/plsql/plsql_constants.htm 3/4
4/2/2019 PL/SQL - Constants and Literals
https://www.tutorialspoint.com/plsql/plsql_constants.htm 4/4