Differences between char, nchar, varchar, varchar2, and nvarchar2 in Oracle

Source: Internet
Author: User
Differences between char, nchar, varchar, varchar2, and nvarchar2 in Oracle
1. Char (Size) And varchar (Size) Difference
Char is a fixed-length field with a maximum length of 2 K bytes;
Varchar is a variable-length field with a maximum length of 4 K bytes;

2. Char(Size)And nchar(Size)Difference
Char if the storage of letters and numbers accounted for 1 byte, the storage of GBK encoding of Chinese Characters in 2 bytes, the storage of UTF-8 encoding of Chinese Characters in 3 bytes;
Nchar defines the number of bytes used to store characters according to the selected character set. Generally, it stores one character (no matter the character or Chinese character) in two bytes)

3. varchar (Size)And varchar2(Size)Difference
In the current version, there is no difference between the two. The maximum length is 4 K Bytes. varchar2 is recommended;

4. varchar2 (size) and nvarchar2 (Size)Difference
The maximum length is 4 K Bytes. The difference is the same as that of char and nchar. (If the database character set length is 2, the maximum length of nvarchar2 is 2 K)

5. Common Features
When an insert statement is executed, if the inserted value is '', it is converted to null, that is, insert... values ('') <=> insert... values (null)
The search condition must use where XX is null.

6. Example
For example, there is a gender field that stores one of the values of "male and female ".
Char (2) and nchar (1)

Http://blog.chinaunix.net/u1/44781/showart_494305.html

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.