Search code examples
sqloraclesqldatatypes

Difference between varchar2(10), varchar2(10 byte) and varchar2(10 char)


I have been told by client to replace varchar2(10 char) by varchar2(10 byte). I exactly don't know the difference in varchar2(10),varchar2(10 char) and varchar2(10 byte). also could you please tell me in which scenario we should use.


Solution

  • VARCHAR2(10 byte) will support up to 10 bytes of data, which could be as few as two characters in a multi-byte character sets.

    VARCHAR2(10 char) could support as much as 40 bytes of information and will support to up 10 characters of data.

    Varchar2(10) uses the current value of NLS_LENGTH_SEMANTICS to determine the limit for the string.

    incase of byte, then it's 10 bytes.

    incase of char, then it's 10 characters.

    In multibyte character sets these can be different! So if NLS_LENGTH_SEMANTICS = byte, you may only be able to store 5 characters in your varchar2. So varchar2(10 char) is explicit. This can store up to 10 characters. Varchar2(10) is implicit. It may store 10 bytes or 10 characters, depending on the DB configuration.

    ocacle ask link