Oracle Database VARCHAR2 (* char) differs from VARCHAR2 (*)

Source: Internet
Author: User

VARCHAR2 (* char) and VARCHAR2 (*)

A Hibernate automatic table was recently used, and when a string is used, the VARCHAR2 type field is created by default, such as setting length=10, after which the field property is Varchar2 (. Char), not VARCHAR2 (10).

Because I didn't notice this before, I checked it on the internet before I knew that the original foundation was not remembered (perhaps it was not contacted at first, at least the latter was always used in the impression). In fact, this two writing is really a bit different, varchar2 (Ten char) represents 10 characters, this type can store 10 multibyte characters, such as 10 Chinese characters, and VARCHAR2 (10) In fact, the city Varchar2 (byte) of the shorthand, Represents two bytes, note that the former is a character and here is a byte, which means that the type cannot store 10 multibyte characters.

varchar and VARCHAR2

VarChar is not fixed in length, for example, you define varchar (20), and when you insert ABC, it takes up only 3 bytes in the database.

VarChar also distinguishes between Chinese and English, this same char.

VARCHAR2 is essentially equivalent to varchar, which is a non-industrial standard varchar defined by Oracle, except that VARCHAR2 NULL in place of varchar null string

The VARCHAR/VARCHAR2 is suitable for the length not fixed, generally does not contain the Chinese situation
To find, to sum up, in case of forgetting. Play the database is relatively few, the proficient not to clap!

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.