What is the difference between varchar, VARCHAR2, nvarchar2 in Oracle?

Source: Internet
Author: User

If the character encoding of Oracle is GBK, then a Chinese character takes up two bytes, but if you use UTF-8, then a Chinese character occupies three bytes. The VARCHAR2 type is used in most cases to ensure better compatibility.

GBK Character Set: VARCHAR2 (10) Can save 5 Chinese, can save 10 English. However, using the length function gets the number of characters actually obtained, namely: the length of 5 Chinese is 5, and 10 English is 10.

NVARCHAR2 (10) can save up to 10 Chinese, at most can only save 10 English, character length is also the number of characters, that is, both Chinese and English are 10.

The length of the VARCHAR2 can be set to a maximum of 4000,nvarchar2 length can be set to 2000, that is, the same is preserved in Chinese, two types can save 2000 Chinese, if the same is in English, varchar can save 4,000 English, NVARCHAR2 can only save 2000 English.

When a table is built in Oracle, varchar is automatically converted to the VARCHAR2 type for creation.

VarChar is also a variable length, and varchar2 is synonymous, the difference is that VARCHAR2 is a type developed by Oracle itself, the user has the empty string as a null storage, with better compatibility.

What is the difference between varchar, VARCHAR2, nvarchar2 in Oracle?

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.