oracle data type

1. Character type
CHAR : A fixed-length string, when the number of digits is insufficient, it will be automatically filled with spaces to reach its maximum length. A non-NULL CHAR(12) always contains 12 bytes of information. A CHAR field can store up to 2,000 bytes of
information.
VARCHAR2 : This is also currently a synonym for VARCHAR. This is a variable-length string, and unlike the CHAR type, it is not space-padded to the maximum length. VARCHAR2(12) may contain 0~

12 bytes of information. VARCHAR2 can store up to 4,000 bytes of information.

Comparison of CHAR and VARCHAR2
CHAR(4) "A" is actually stored in the database as "A"
"ABCDE" super long error
VARCHAR2(4) "A" is still stored as "A"
"ABCDE" super long error
Chinese characters: each How many bytes Chinese characters occupy depends on the specific encoding method, such as UTF-8 (1-3 bytes),
GB2312 (2 bytes), GBK (2 bytes), GB18030 (1, 2, 4 bytes)

 

2. Number type

NUMBER : This data type can store numbers with a precision of up to 38 digits. Each number is stored in a variable-length field, whose length is between 0 and 22 bytes. Oracle 's NUMBER type has high precision, much higher than the regular FLOAT and DOUBLE types in many programming languages.

NUMBER( p,s ) p means precision (total length) s means decimal place and rounding

NUMBER(10,3) 10 is the total length, 3 is the length of the decimal places
123.456
123.4567 : will be stored as 123.457
12345679.899 : the precision is too long, 10 is the total length, 3 is the decimal place, and the integer bits are 10-3=7 Bit
NUMBER(10)==NUMBER(10,0)  Java .lang.Integer
NUMBER(19)==NUMBER(19,0) java.lang.Long

 

3. Date type

DATE : A 7-byte fixed-width date/time data type. There are always 7 properties, including: century, year of the century, month, day of the month, hours, minutes, and seconds.

TIMESTAMP : A 7-byte or 12. byte fixed-width date/time data type. It differs from the DATE data type because a TIMESTAMP can contain fractional seconds; a TIMESTAMP with fractional seconds can hold up to 9 digits to the right of the decimal point.

 

4. Binary and large text data

BLOB : (binary large object) In Oracle9i and earlier versions, this data type allows storage of up to 4GB of data, and in Oracle 10g and later versions allows storage of up to (4GB) × (database block size) bytes data. BLOBs contain "binary" data that does not require character set conversion, and are suitable for storing spreadsheets, word processing documents, image files, etc.

 

CLOB : (Character Large Object) In Oracle9i and earlier versions, this data type allows storage of up to 4GB of data, and in Oracle 10g and later versions allows storage of up to (4GB) × (database block size) bytes data. CLOB contains information to perform character set conversion. This data type is good for storing plain text information.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326457442&siteId=291194637