The difference of CHAR,VARCHAR,VARCHAR2 in Oracle ____oracle

Source: Internet
Author: User
Difference:
1. The length of the char is fixed, the length of the VARCHAR2 can vary, for example, the storage string "abc", for Char (20), which means that the characters you store will occupy 20 bytes (including 17 null characters), while the same VARCHAR2 (20) occupies a length of 3 bytes. 20 is only the maximum value when you store the characters less than 20 o'clock, stored by the actual length.
2. The efficiency of char is slightly higher than that of VARCHAR2.
3. At present varchar is synonymous with VARCHAR2. Industry-standard varchar types can store empty strings, but Oracle does not, although it retains the right to do so later. Oracle himself developed a data type VARCHAR2, which is not a standard varchar that stores null values in a database where varchar columns can store an empty string. Oracle recommends using VARCHAR2 instead of varchar if you want to be able to have backwards compatibility.

When to use char and when to use VARCHAR2.
Char and VARCHAR2 are a pair of contradictory unity, the two are complementary relations.
VARCHAR2 saves more space than Char, and is slightly less efficient than char, which means that if you want to be efficient, you have to sacrifice a certain amount of space, which is what we often say in database design, ' space for efficiency '.
VARCHAR2 saves space than Char, but if a VARCHAR2 column is often modified and the length of each modified data varies, this causes a ' row migration ' (row migration) phenomenon, which creates redundant I/O, which is avoided in database design and tuning. , it would be better to use char instead of VARCHAR2 in this case.
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.