Development Environment: some table field types are defined as varchar2 (20) 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
-----------------------------------------------------------------------------
Nls_length_semantics string byte
SQL> 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 null? 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
-----------------------------------------------------------------------------
ID number (10)
Description varchar2 (20)
Note: SYS and system are not affected by the nls_length_semantics and are always byte
Do not arbitrarily modify the system-level nls_length_semantics. Otherwise, some finished suites such as EBS may fail to run normally.