The difference of VARCHAR,VARCHAR2,NVARCHAR,NVARCHAR2 in Oracle __oracle

Source: Internet
Author: User

--varchar,varchar2

Contact:
1.varchar/varchar2 used to store variable-length strings
such as varchar (20), stored in the string ' ABC ', the field in the database is only 3 bytes, not 20 bytes
The maximum value for 2.size is 4000, and the minimum value is 1, and its value indicates the number of bytes, such as
varchar (20) indicates that the maximum number of 20 bytes of content can be stored

Difference:
1.varchar2 all characters are accounted for two bytes (in general), varchar only for Chinese characters and Full-width and other characters accounted for two bytes, numbers, English characters, etc. are a byte;
2.VARCHAR2 the null string equivalent to NULL processing, and varchar still in accordance with the empty string processing;
3.varchar2 characters need to be stored in several bytes, looking at the character set used by the database,
For example GBK, Chinese characters will occupy two bytes, English one
If it is UTF-8, the Chinese character generally occupies 3 bytes, English or 1.
But in general, we think it is two byte processing, because the Oracle installation time by default we all choose GBK encoding format, but we are in the page to do the input string length of the check, or the maximum length of the database design field except 3来 as the maximum-----to prevent the database from transplanting when the different encoding format;
For example: VARCHAR2 (10), in general, the maximum storage of 5 characters, 10 characters

--nvarchar,nvarchar2
Contact:
1.nvarchar/nvarchar2 used to store variable-length strings
The maximum value for 2.size is 4000, and the minimum value is 1, and its value represents the number of characters, not the number of bytes
3. These two types are more suitable for storing Chinese

Difference:
1.nvarchar characters in Chinese are generally in the 2 byte calculation, English numerals, etc. according to one's own calculation
All characters in 2.NVARCHAR2 are calculated according to 2 bytes;
3.nvarchar2 Although more space, but it has better compatibility, all recommended use;

VARCHAR2 (size)

A variable-length string with a maximum length of size bytes, a maximum size of 4000, and a minimum of 1; You must specify a VARCHAR2 size;

NVARCHAR2 (size)

A variable-length string, based on the selected national character set, with a maximum length of size characters or bytes; The maximum size depends on the number of bytes required to store each character, with an upper limit of 4000; You must specify a NVARCHAR2 size;

Number (p,s)

A numerical value with a precision of p and a value range of S; the range of precision p is from 1 to 38; The range of the range S is from-84 to 127;
For example: Number (5,2) indicates that the integer part is the largest 3 digits, and the decimal part is 2 bits;
Number (5,-2) represents the integer part of the maximum of 7, where the reciprocal 2 digits of the integer are 0, and the preceding rounding.
Number means the default value, which is equivalent to number (5);

LONG

Variable-length character data with a length of up to 2G bytes;

DATE

Valid date range from January 1, 4712 to A.D. December 31, 4712

RAW (size)

Raw binary data of size byte, the maximum size is 2000 bytes; You must specify a size for raw;

LONG RAW

Raw binary data of variable length, which can reach up to 2G bytes;

CHAR (size)

Fixed-length character data whose length is size byte; The maximum size is 2000 bytes, while the minimum and default values are 1;

NCHAR (size)

is also a fixed length. Defined according to the Unicode standard

CLOB

A large object that can hold single-byte characters, a character set with unequal widths, and a maximum of 4G bytes

NCLOB

A large object that accommodates a single byte of character, does not support a character set of unequal widths, a maximum of 4G bytes, and stores a national character set

BLOB

A binary large object; maximum 4G bytes

BFILE

A locator that contains a large binary file that is stored outside the database, allowing the presence of an external LOB on the database server with character stream I/O, and a maximum size of 4G bytes.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.