PL SQL3
PL SQL3
Each value in PL/SQL such as a constant, variable and parameter has a data type
that determines the
storage format, valid values and allowed operations.
PL/SQL has two kinds of data types: scalar and composite. The scalar types are
types that store single
values such as number, Boolean, character, and datetime whereas the composite types
are types that
store multiple values, for example, record and collection.
This tutorial explains the scalar data types that store values with no internal
components.
Number
Boolean
Character
Datetime
A scalar data type may have subtypes. A subtype is a data type that is a subset of
another data type,
which is its base type. A subtype further defines a base type by restricting the
value or size of the base
data type.
Note that PL/SQL scalar data types include SQL data types and its own data type
such as Boolean.
The numeric data types represent real numbers, integers, and floating-point
numbers. They are stored
as NUMBER , IEEE floating-point storage types ( BINARY_FLOAT and BINARY_DOUBLE ),
and PLS_INTEGER .
The data types NUMBER , BINARY_FLOAT , and BINARY_DOUBLE are SQL data types.
Because PLS_INTEGER datatype uses hardware arithmetic, they are faster than NUMBER
operations,
which uses software arithmetic.
In addition, PLS_INTEGER values require less storage than NUMBER . Hence, you
should always use
PLS_INTEGER values for all calculation in its range to increase the efficiency of
programs.
PLS_INTEGER
subtypes
Description
programming
The BOOLEAN datatype has three data values: TRUE, FALSE, and NULL. Boolean values
are typically used
in control flow structure such as IF-THEN, CASE, and loop statements like LOOP, FOR
LOOP, and WHILE
LOOP.
SQL does not have the BOOLEAN data type, therefore, you cannot:
The character data types represent alphanumeric text. PL/SQL uses the SQL character
data types such
as CHAR , VARCHAR2 , LONG , RAW , LONG RAW , ROWID , and UROWID .
The datetime data types represent dates, timestamp with or without time zone and
intervals. PL/SQL
datetime data types are DATE , TIMESTAMP , TIMESTAMP WITH TIME ZONE , TIMESTAMP
WITH LOCAL TIME
ZONE , INTERVAL YEAR TO MONTH , and INTERVAL DAY TO SECOND .
Data types have synonyms for compartibility with non-Oracle data sources such as
IBM Db2, SQL
Server. And it is not a good practice to use data type synonym unless you are
accessing a non-Oracle
Database.