Type | Description |
CHAR[(length [BYTE | CHAR])] | Fixed-length character data of length bytes or characters and padded with trailing spaces. Maximum length is 2,000 bytes. |
VARCHAR2(length [BYTE | CHAR]) | Variable-length character data of up to length bytes or characters. Maximum length is 4,000 bytes. |
NCHAR[(length)] | Fixed-length Unicode character data of length characters. Number of bytes stored is 2 * length for AL16UTF16 encoding and 3 * length for UTF8. Maximum length is 2,000 bytes. |
NVARCHAR2(length) | Variable-length Unicode character data of length characters. Number of bytes stored is 2 * length for AL16UTF16 encoding and 3 * length for UTF8 encoding. Maximum length is 4,000 bytes. |
BINARY_FLOAT | Stores a single precision 32-bit floating-point number. Operations involving BINARY_FLOAT are typically performed faster than on NUMBERs. BINARY_FLOAT requires 5 bytes of storage space. |
BINARY_DOUBLE | Stores a double precision 64-bit floating-point number. Operations involving BINARY_DOUBLE are typically performed faster than on NUMBERs. BINARY_DOUBLE requires 9 bytes of storage space. |
NUMBER(precision, scale) and NUMERIC(precision, scale) | Variable-length number; precision is the maximum number of digits (in front of and behind a decimal point, if used) that may be used for the number. The maximum precision supported is 38; scale is the maximum number of digits to the right of a decimal point (if used). If neither precision nor scale is specified, then a number with up to a precision and scale of 38 digits may be supplied (meaning you can supply a number with up to 38 digits, and any of those 38 digits may be in front of or behind the decimal point). |
DEC and DECIMAL | Subtype of NUMBER. A fixed-point decimal number with up to 38 digits of decimal precision. |
DOUBLE PRECISION and FLOAT | Subtype of NUMBER. A floating-point number with up to 38 digits of precision. |
REAL | Subtype of NUMBER. A floating-point number with up to 18 digits of precision. |
INT, INTEGER, and SMALLINT | Subtype of NUMBER. An integer with up to 38 digits of decimal precision. |
DATE | Date and time with the century, all four digits of year, month, day, hour (in 24-hour format), minute, and second. May be used to store a date and time between January 1, 4712 B.C. and December 31, 4712 A.D. Default format is specified by the NLS_DATE_FORMAT parameter (for example: DD-MON-RR). |
INTERVAL YEAR[(years_precision)] TO MONTH | Time interval measured in years and months; years_precision specifies the precision for the years, which may be an integer from 0 to 9 (default is 2). Can be used to represent a positive or negative time interval. |
INTERVAL DAY[(days_precision)] TO SECOND[(seconds_precision)] | Time interval measured in days and seconds; days_precision specifies the precision for the days, which is an integer from 0 to 9 (default is 2); seconds_precision specifies the precision for the fractional part of the seconds, which is an integer from 0 to 9 (default is 6). Can be used to represent a positive or negative time interval. |
TIMESTAMP[(seconds_precision)] | Date and time with the century, all four digits of year, month, day, hour (in 24-hour format), minute, and second; seconds_precision specifies the number of digits for the fractional part of the seconds, which can be an integer from 0 to 9 (default is 6). Default format is specified by the NLS_TIMESTAMP_FORMAT parameter. |
TIMESTAMP[(seconds_precision)] WITH TIME ZONE | Extends TIMESTAMP to store a time zone. The time zone can be an offset from UTC, such as ??-5:0', or a region name, such as ??US/Pacific'. Default format is specified by the NLS_TIMESTAMP_TZ_FORMAT parameter. |
TIMESTAMP[(seconds_precision)] WITH LOCAL TIME ZONE | Extends TIMESTAMP to convert a supplied datetime to the local time zone set for the database. The process of conversion is known as normalizing the datetime. Default format is specified by the NLS_TIMESTAMP_FORMAT parameter. |
CLOB | Variable length single-byte character data of up to 128 terabytes. |
NCLOB | Variable length Unicode national character set data of up to 128 terabytes. |
BLOB | Variable length binary data of up to 128 terabytes. |
BFILE | Pointer to an external file. |
LONG | Variable length character data of up to 2 gigabytes. Superceded by CLOB and NCLOB types, but supported for backwards compatibility. |
RAW(length) | Variable length binary data of up to length bytes. Maximum length is 2,000 bytes. Superceded by BLOB type, but supported for backwards compatibility. |
LONG RAW | Variable length binary data of up to 2 gigabytes. Superceded by BLOB type but supported for backwards compatibility. |
ROWID | Hexadecimal string used to represent a row address. |
UROWID[(length)] | Hexadecimal string representing the logical address of a row of an index-organized table; length specifies the number of bytes. Maximum length is 4,000 bytes (also default). |
REF object_type | Reference to an object type. |
VARRAY | Variable length array. This is a composite type and stores an ordered set of elements. |
NESTED TABLE | Nested table. This is a composite type and stores an unordered set of elements. |
XMLType | Stores XML data. |
User defined object type | You can define your own object type and create objects of that type. |
PL/SQL only data type | PL/SQL only data type |
BOOLEAN | Boolean value (TRUE, FALSE, or NULL). |
BINARY_INTEGER | Integer between C231 (C2,147,483,648) and 231 (2,147,483,648). |
NATURAL | Subtype of BINARY_INTEGER. A non-negative integer. |
NATURALN | Subtype of BINARY_INTEGER. A non-negative integer (and cannot be NULL). |
POSITIVE | Subtype of BINARY_INTEGER. A positive integer. |
POSITIVEN | Subtype of BINARY_INTEGER. A positive integer (and cannot be NULL). |
SIGNTYPE | Subtype of BINARY_INTEGER. An integer of C1, 0, or 1. |
PLS_INTEGER | Integer between C231 (C2,147,483,648) and 231 (2,147,483,648). Similar to BINARY_INTEGER, but computations involving PLS_INTEGER values are faster. |
STRING | Same as VARCHAR2. |
RECORD | Composite of a group of other types. Similar to a structure in C. |
REF CURSOR | Pointer to a set of rows. |
These datatypes can be used for creating simple scalar variables.
They can be combined into structures such as records or PL/SQL tables.
A scalar variable is a variable that is not made up of some combination of other variables.
Scalar variables don't have internal components that you can manipulate individually.
They are often used to build up more complex datatypes such as records and arrays.
Some of the datatype names match those used by Oracle for defining database columns.
In most cases the definitions are the same for both the database and PL/SQL, but there are a few differences.
PL/SQL also provides subtypes of some datatypes.
A subtype represents a special case of a datatype.
A subtype represents a narrower range of values than the parent type.
For example, POSITIVE is a subtype of BINARY_INTEGER that holds only positive values.
21.1.Introduction | ||||
21.1.1. | Block Structure | |||
21.1.2. | Your First PL/SQL Block | |||
21.1.3. | The slash character (/) at the end of the example executes the PL/SQL. | |||
21.1.4. | You can declare the whole string to be enclosed in quotes by using the construct q'!text!' | |||
21.1.5. | All identifiers within the same scope must be unique. | |||
21.1.6. | Building Expressions with Operators | |||
21.1.7. | PL/SQL datatypes | |||
21.1.8. | Variable Naming Rules | |||
21.1.9. | Introducing the Main Data type Groups |