-- Varchar, varchar2
Contact:
1. varchar/varchar2 is used to store variable-length strings
For example, if varchar (20) is saved to the string 'abc', this field occupies only 3 bytes in the database, not 20 bytes.
2. The maximum value of size is 4000, while the minimum value is 1. Its value indicates the number of bytes, for example
Varchar (20) indicates that up to 20 bytes of content can be stored.
Differences:
1. varchar2 processes all characters in two bytes (generally). varchar only occupies two bytes of Chinese characters and full-angle characters, and each digit or English character is one byte;
2. varchar2 treats empty strings as null, while varchar still processes empty strings;
3. varchar2 characters must be stored in several bytes, depending on the character set used by the database,
For example, GBK occupies two bytes of Chinese characters and one English character
If it is UTF-8, Chinese characters generally occupy 3 bytes, English or 1.
However, we generally think it is two-byte processing, because we select the GBK encoding format by default during Oracle installation, but when we verify the input string length on the page, or use the maximum length of the database design field except 3 as the maximum length ----- prevent different encoding formats from being set during database transplantation;
For example: varchar2 (10). Generally, it can contain up to 5 Chinese characters and 10 characters.
-- Nvarchar, nvarchar2
Contact:
1. nvarchar/nvarchar2 is used to store variable-length strings
2. The maximum value of size is 4000, while the minimum value is 1. Its value indicates the number of characters, not the number of bytes.
3. These two types are more suitable for storing Chinese Characters
Differences:
1. If the nvarchar character is Chinese, it is generally calculated in 2 bytes, and the English number is calculated by yourself.
2. All characters in nvarchar2 are calculated in two bytes;
3. Although nvarchar2 occupies more space, it has better compatibility and is recommended for all applications;
Varchar2 (size)
The maximum length of a variable-length string is size bytes. the maximum size is 4000, and the minimum value is 1. You must specify the size of varchar2;
Nvarchar2 (size)
A variable-length string. Based on the selected national character set, the maximum length is size characters or bytes. the maximum size is determined by the number of bytes required for each character. The maximum size is 4000; you must specify the size of an nvarchar2;
Number (P, S)
A value with a precision of P and a value range of S; a value with a precision of 1 to 38; A value range of S from-84 to 127;
For example, number (5, 2) indicates the integer part has a maximum of three digits and the fractional part has two digits;
Number (5,-2) indicates the maximum value of the integer part of the number is 7. The reciprocal two digits of an integer are 0, and the first integer is rounded up.
Number indicates that the default value is used, which is equivalent to number (5 );
Long
Variable-length character data, which can be 2 GB in length;
Date
Valid date range: From January 1, January 1, 4712 BC to January 1, December 31, 4712
Raw (size)
The size is the size of the original binary data. The maximum size is 2000 bytes. You must specify a size for raw;
Long raw
Up to 2 GB of original binary data with a variable length;
Char (size)
The length of fixed-length character data is size bytes. the maximum size is 2000 bytes, and the minimum and default values are 1;
Nchar (size)
It is also a fixed length. Defined according to Unicode standards
Clob
A large character object that can contain single-byte characters. character sets of different widths are not supported. The maximum size is 4 GB.
Nclob
A large character object that can contain single-byte characters. character sets of different widths are not supported. The maximum size is 4 GB.
Blob
A large binary object; up to 4G bytes
Bfile
A locator that contains a large binary file, which is stored outside the database, so that the external lob on the database server can be accessed by the ingress stream I/O. The maximum size is 4 GB.