ORACLE basic data types, also called built-in data types (built-in datatypes), can be divided by type: string type, numeric type, large object type (LOB type), date type, LONG RAW & RAW type, ROWID & UROWID type.
1. Character type
type of data
length
illustrate
CHAR(n BYTE/CHAR)
The default is 1 byte, the maximum n value is 2000
Spaces are padded at the end to reach the specified length. If the maximum length is exceeded, an error will be reported. The default specified length is the number of bytes, and the character length can range from 1 byte to four bytes.
NCHAR(n)
Default is 1 character, maximum storage content is 2000 bytes
Spaces are padded at the end to reach the specified length, n is the number of Unicode characters. Default is 1 byte.
NVARCHAR2(n)
The maximum length must be specified, and the maximum storage content is 4000 bytes.
Variable length type. n is the number of Unicode characters
VARCHAR2(n BYTE/CHAR)
The maximum length must be specified, at least 1 byte or 1 character, and the maximum n value is 4000
Variable length type. An error is reported if the maximum length is exceeded. By default, a string of length 0 is stored.
VARCHAR
Same as VARCHAR2
Not recommended for use
2. Numeric type
type of data
length
illustrate
NUMBER(p[,s])
1-22 bytes. P value range is 1 to 38 S value range is -84 to 127
Stores a fixed-point number with an absolute value ranging from 1.0 x 10 -130 to 1.0 x 10 126. If the value is greater than or equal to 1.0 x 10 126, an error will be reported. p is the number of meaningful decimal digits, the positive value s is the number of decimal places, and the negative value s represents the number of decimal places rounded to the left of the decimal point.
BINARY_FLOAT
5 bytes, including a length byte.
32-bit single-precision floating point number type. There is 1 sign bit, 8 exponent bits, and 23 mantissa bits.
BINARY_DOUBLE
9 bytes, including a length byte.
64-bit double-precision floating-point number type.
3. Large object types
type of data
length
illustrate
BLOB
Maximum is (4GB-1)*database block size
Store unstructured binary files. Support transaction processing.
CLOB
Maximum is (4GB-1)*database block size
Store single-byte or multi-byte character data. Support transaction processing.
NCLOB
Maximum is (4GB-1)*database block size
Store Unicode data. Support transaction processing.
BFILE
Maximum 2 32-1 bytes
The LOB address points to a binary file on the file system, maintaining directory and file names. Does not participate in transaction processing. Only read-only operations are supported.
4. Time and time interval types
time field
Time type valid values
Valid values for time interval type
YEAR
-4712 to 9999, including 0
any integer
MONTH
01 to 12
0 to 11
DAY
01 to 31
any integer
HOUR
00 to 23
0 to 23
MINUTE
00 to 59
0 to 59
SECOND
00 to 59.9(n), 9(n) is not applicable to DATE type
0 to 59.9(n)
TIMEZONE_HOUR
-1 to 14, not applicable to DATE and TIMESTAMP types
unavailable
TIMEZONE_MINUTE 00 to 59, not available with DATE and TIMESTAMP types
TIMEZONE_REGION
unavailable
TIMEZONE_ABBR
unavailable
type of data
length
illustrate
DATE
7 bytes
The default value is the year and month of SYSDATE, and the day is 01. Contains a time field. If the inserted value does not have a time field, the default value is: 00:00:00 or 12:00:00 for 24-hour and 12-hour clock time. There are no minutes, seconds or time zones.
TIMESTAMP [(fractional_seconds_precision)]
7 to 11 bytes
Fractional_seconds_precision is the number of decimal places in the Oracle storage seconds value. The default is 6 and the optional value is 0 to 9. There is no time zone.
TIMESTAMP [(fractional_seconds_precision)] WITH TIME ZONE
13 bytes
Use UTC, including fields YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, TIMEZONE_HOUR, TIMEZONE_MINUTE
TIMESTAMP [(fractional_seconds_precision)] WITH LOCAL TIME ZONE
7 to 11 bytes
The database time zone is used when saving, and the session time zone is used when retrieving.
INTERVAL YEAR [(year_precision)] TO MONTH
5 bytes
包含年、月的时间间隔类型。year_precision是年字段的数字位数,默认为2,可取0至9。
INTERVAL DAY [(day_precision)][(fractional_seconds_precision)]