Home Database Mysql Tutorial The difference between data types in oracle

The difference between data types in oracle

Dec 20, 2016 pm 02:16 PM
oracle

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)

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Function to calculate the number of days between two dates in oracle Function to calculate the number of days between two dates in oracle May 08, 2024 pm 07:45 PM

Function to calculate the number of days between two dates in oracle

How long will Oracle database logs be kept? How long will Oracle database logs be kept? May 10, 2024 am 03:27 AM

How long will Oracle database logs be kept?

The order of the oracle database startup steps is The order of the oracle database startup steps is May 10, 2024 am 01:48 AM

The order of the oracle database startup steps is

How to use interval in oracle How to use interval in oracle May 08, 2024 pm 07:54 PM

How to use interval in oracle

Oracle database server hardware configuration requirements Oracle database server hardware configuration requirements May 10, 2024 am 04:00 AM

Oracle database server hardware configuration requirements

How to see the number of occurrences of a certain character in Oracle How to see the number of occurrences of a certain character in Oracle May 09, 2024 pm 09:33 PM

How to see the number of occurrences of a certain character in Oracle

How to determine whether two strings are contained in oracle How to determine whether two strings are contained in oracle May 08, 2024 pm 07:00 PM

How to determine whether two strings are contained in oracle

How much memory does oracle require? How much memory does oracle require? May 10, 2024 am 04:12 AM

How much memory does oracle require?

See all articles