PL/SQL: Data Types Cheat Sheet

ScalarSingle values with no internal components, such as a NUMBER, DATE, or BOOLEAN.
Large Object (LOB)Pointers to large objects that are stored separately from other data items, such as text, graphic images, video clips, and sound waveforms.
CompositeData items that have internal components that can be accessed individually. For example, collections and records.
ReferencePointers to other data items.
Scalar Data Types and Subtypes
Date TypeDescription
NumericNumeric values on which arithmetic operations are performed.
CharacterAlphanumeric values that represent single characters or strings of characters.
BooleanLogical values on which logical operations are performed.
DatetimeDates and times.
Numeric Data Types and Subtypes
Data TypeDescription
PLS_INTEGERSigned integer in range -2,147,483,648 through 2,147,483,647, represented in 32 bits
BINARY_INTEGERSigned integer in range -2,147,483,648 through 2,147,483,647, represented in 32 bits
BINARY_FLOATSingle-precision IEEE 754-format floating-point number
BINARY_DOUBLEDouble-precision IEEE 754-format floating-point number
NUMBER(prec, scale)Fixed-point or floating-point number with absolute value in range 1E-130 to (but not including) 1.0E126. A NUMBER variable can also represent 0
DEC(prec, scale)ANSI specific fixed-point type with maximum precision of 38 decimal digits
DECIMAL(prec, scale)IBM specific fixed-point type with maximum precision of 38 decimal digits
NUMERIC(pre, secale)Floating type with maximum precision of 38 decimal digits
DOUBLE PRECISIONANSI specific floating-point type with maximum precision of 126 binary digits (approximately 38 decimal digits)
FLOATANSI and IBM specific floating-point type with maximum precision of 126 binary digits (approximately 38 decimal digits)
INTANSI specific integer type with maximum precision of 38 decimal digits
INTEGERANSI and IBM specific integer type with maximum precision of 38 decimal digits
SMALLINTANSI and IBM specific integer type with maximum precision of 38 decimal digits
REALFloating-point type with maximum precision of 63 binary digits (approximately 18 decimal digits)

Below is a valid declaration

DECLARE 
   num1 INTEGER; 
   num2 REAL; 
   num3 DOUBLE PRECISION; 
BEGIN 
   null; 
END; 
/ 
Character Data Types and Subtypes
Data TypeDescription
CHARA fixed-length character string with a maximum size of 32,767 bytes
VARCHAR2A variable-length character string with a maximum size of 32,767 bytes
RAWA variable-length binary or byte string with a maximum size of 32,767 bytes, not interpreted by PL/SQL
NCHARA fixed-length national character string with a maximum size of 32,767 bytes
NVARCHAR2A variable-length national character string with a maximum size of 32,767 bytes
LONGA variable-length character string with a maximum size of 32,760 bytes
LONG RAWA variable-length binary or byte string with a maximum size of 32,760 bytes, not interpreted by PL/SQL
ROWIDPhysical row identifier, the address of a row in an ordinary table
UROWIDUniversal row identifier (physical, logical, or foreign row identifier)
Datetime and Interval Types
Field NameValid Datetime ValuesValid Interval Values
YEAR-4712 to 9999 (excluding year 0)Any nonzero integer
MONTH01 to 120 to 11
DAY01 to 31 (limited by the values of MONTH and YEAR, according to the rules of the calendar for the locale)Any nonzero integer
HOUR00 to 230 to 23
MINUTE00 to 590 to 59
SECOND00 to 59.9(n), where 9(n) is the precision of time fractional seconds0 to 59.9(n), where 9(n) is the precision of interval fractional seconds
TIMEZONE_HOUR-12 to 14 (range accommodates daylight savings time changes)Not applicable
TIMEZONE_MINUTE00 to 59Not applicable
TIMEZONE_REGIONFound in the dynamic performance view V$TIMEZONE_NAMESNot applicable
TIMEZONE_ABBRFound in the dynamic performance view V$TIMEZONE_NAMESNot applicable
PL/SQL Large Object (LOB) Data Types
Data TypeDescriptionSize
BFILEUsed to store large binary objects in operating system files outside the database.System-dependent. Cannot exceed 4 gigabytes (GB).
BLOBUsed to store large binary objects in the database.8 to 128 terabytes (TB)
CLOBUsed to store large blocks of character data in the database.8 to 128 TB
NCLOBUsed to store large blocks of NCHAR data in the database.8 to 128 TB

Leave a Reply

Your email address will not be published. Required fields are marked *