Introduction to five types of Oracle characters

Source: Internet
Author: User

Are you familiar with Oracle character types? Today, we will summarize it, including CHAR, NCHAR, LONG, VARCHAR2 (VARCHAR), and NVARCHAR2 Oracle character types. The following articles describe these types in detail.

CHAR, an Oracle string that describes a fixed length. If the actual value is not enough to define the length, the system will fill it with spaces. The statement is as follows: CHAR (L). L is the Oracle string length. The default value is 1. It can be a variable of up to 32767 characters and 2000 of data is stored in ORACLE8.

VARCHAR2 (VARCHAR) describes variable-length strings. The declaration method is as follows: VARCHAR2 (L), L is the string length, there is no default value, as the variable is up to 32767 bytes, as the maximum data storage in ORACLE8 is 4000. In a multi-byte environment, the actual number of Oracle characters stored may be less than L.

For example, when the language environment is Chinese (SIMPLIFIED CHINESE_CHINA.ZHS16GBK), a VARCHAR2 (200) data column can save 200 English or 100 Chinese characters.

LONG can be used in database storage to store up to 2 GB of data. As a variable, it can represent a variable string with a maximum length of 32760 bytes.

NCHAR, NVARCHAR2, National Oracle character set, which is closely related to the language set specified by the Environment Variable NLS. The usage is the same as that of CHAR and VARCHAR2.

(Varchar2 is a unique data type provided by oracle. In any version, oracle ensures that the data type is up and down compatible, but varchar is not guaranteed. Because varchar is the data type provided by standard SQL, it may change as the SQL standard changes. varchar2 is recommended .)

CHAR if the storage of letters and numbers accounted for 1 byte, the storage of GBK encoding of Chinese Characters in 2 bytes, the storage of UTF-8 encoding of Chinese Characters in 3 bytes; NCHAR defines the number of bytes used to store characters according to the selected Oracle character set. Generally, it stores one character (no matter the character or Chinese character) in two bytes ). Similarly, VARCHAR2 and NVARCHAR2 are different .)

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.