Home > Database > Mysql Tutorial > body text

The difference between data types in oracle

巴扎黑
Release: 2016-12-20 14:16:54
Original
1125 people have browsed it

1. The length of CHAR is fixed, but the length of VARCHAR2 can be changed. For example, to store the string "abc", for CHAR (20), it means that the characters you store will occupy 20 bytes (including 17 null characters). The same VARCHAR2 (20) only occupies a length of 3 bytes, and 20 is only the maximum value. When the characters you store are less than 20, they are stored according to the actual length.
 2. CHAR is slightly more efficient than VARCHAR2.
 3. Currently VARCHAR is a synonym for VARCHAR2. The industry-standard VARCHAR type can store empty strings, but Oracle does not do so, although it reserves the right to do so in the future. Oracle has developed a data type VARCHAR2. This type is not a standard VARCHAR. It changes the feature that the varchar column in the database can store empty strings to store NULL values. If you want backward compatibility, Oracle recommends using VARCHAR2 instead of VARCHAR.
 When should you use CHAR and when should you use varchar2?
 CHAR and VARCHAR2 are a contradictory unity, and the two are complementary.
 VARCHAR2 saves space than CHAR, but is slightly less efficient than CHAR. That is, in order to gain efficiency, a certain amount of space must be sacrificed. This is what we often call 'trading space for efficiency' in database design.
 Although VARCHAR2 saves space than CHAR, if a VARCHAR2 column is frequently modified, and the length of the modified data is different each time, this will cause a 'Row Migration' phenomenon, which will cause redundant I/O. This should be avoided in database design and adjustment. In this case, it would be better to use CHAR instead of VARCHAR2. (Dynasty Network wangchao.net.cn)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!