Differences between varchar2 (20) and varchar2 (20 bytes) in Oracle

Source: Internet
Author: User

Differences between varchar2 (20) and varchar2 (20 byte) in Oracle Development Environment: some table field types are defined as varchar2 (20) and some table field types are defined as varchar2 (20 byte) is varchar2 (20) the same as varchar2 (20 byte? The difference is determined by the database parameter NLS_LENGTH_SEMANTICS, which has two units: char (character) or byte. The default value of this parameter is BYTE. Therefore, by default, varchar2 (20) = varchar2 (20 bytes ). If the parameter value is CHAR, It is not equal. Suggestion: Use a unified format such as varchar2 (20) Demo: SQL> show parameter nls_length_semantics; name type value generation ----------- ------------------------------ nls_length_semantics string BYTESQL> create table tab1 (2 id number (10), 3 description varchar2 (20) 4); Table created. SQL> create table tab2 (2 id number (10), 3 description varchar2 (20 char) 4); Table created. SQL> desc tab1; Name Nu Ll? Type ----------------------------------------- -------- ------------------------------ id number (10) DESCRIPTION VARCHAR2 (20) SQL> desc tab2; Name Null? Type ----------------------------------------- -------- ---------------------------- id number (10) DESCRIPTION VARCHAR2 (20 CHAR) SQL> alter session set nls_length_semantics = char; Session altered. SQL> create table tab3 (2 id number (10), 3 description varchar2 (20) 4); Table created. SQL> desc tab1; Name Null? Type ----------------------------------------- -------- ---------------------------- id number (10) DESCRIPTION VARCHAR2 (20 BYTE) SQL> desc tab2; Name Null? Type ----------------------------------------- -------- ------------------------------ id number (10) DESCRIPTION VARCHAR2 (20) SQL> desc tab3; Name Null? Type authorization -------- ---------------------------- id number (10) DESCRIPTION VARCHAR2 (20) Note: For SYS and SYSTEM, this NLS_LENGTH_SEMANTICS is not affected. If it is a BYTE, do not modify the SYSTEM-level nls_length_se, otherwise, some finished kits, such as EBS, may not work properly.

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.