Oracle discusses char varchar VARCHAR2 data type selection __oracle

Source: Internet
Author: User

http://www.javaeye.com/topic/133972

These 3 string data types are the most we use, and how we use them in database design. First, let's analyze 3 data types for descriptions: 1.       The length of Char char is fixed, up to 2000 characters long. 2. varchar and VARCHAR2 can be sure that Oracle is currently able to use the varchar data type, but the difference between them I looked at a lot of data and did not find an accurate answer the most common word is that Oracle's varchar is just          VARCHAR2 's alias is synonymous.   Second, some people think that varchar is a variable string with a maximum length of 2000 (consistent with varchar in SQL Server), while the varchar2 maximum length is 4000. Knowing their characteristics, we'll discuss the use of the distinction between 1.char and varchar, varchar2 because varchar and varchar2 are similar, let's discuss the difference between Char and their use: varchar and VARCHAR2 ratio Char saves space and is a little 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 '.

varchar and varchar2 save space than Char, but if a varchar and VARCHAR2 columns are often modified and the length of each modified data varies, this causes a ' row migration ' (row migration) phenomenon, which results in redundant I/O. is to be avoided in database design and tuning, in which case it would be better to use char instead of varchar and VARCHAR2.

Of course, there is a situation like the identity card of the almost unchanged length of the field can consider using char, to achieve higher efficiency.

2. varchar and VARCHAR2

Here is the point, the difference between us in SQL Server we already have a basic understanding, we may all know, the most is to review, but Oracle added a VARCHAR2 type, is not used by everyone before.

Because Oracle guarantees that the data type is up and down backwards in any version, it does not guarantee varchar, and there are generally varchar this data type in other data.

So I have come to the following conclusions:

Do not use varchar if you want to be compatible with a new Oracle version of the database, and do not use VARCHAR2 if you want to be compatible with other databases outside of 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.