Difference Between Varchar and Varchar2
Introduction:
ORACLE suggested New Data Type VARCHAR2 which is going to replace VARCHAR. In this tutorial, we learn the difference between varchar and varchar2 with an example. A VARCHAR2 one ORACLE data type is stored character string data in one particular column. We should use VARCHAR2 instead of VARCHAR. Because VARCHAR occupies space for the NULL values but VARCHAR2 not occupy space.
Difference Between Varchar and Varchar2 :
VARCHAR
VARCHAR can store the 2000 bytes of characters.
VARCHAR occupies space for the NULL values.
VARCHAR is an ANSI standard.
VARCHAR is external datatype.
VARCHAR is allocated the fixed size of data irrespective of the input.
Syntax: variable_name varchar(10)
Example: SQL> create table test (my_char varchar(20));<br>Table created.
VARCHAR2
VARCHAR2 can store the 4000 bytes of characters.
VARCHAR2 does not occupy the space.
VARCHAR2 is Oracle standard.
VARCHAR2 is internal datatype.
VARCHAR2 is allocated the variable size of data based on input.
Syntax: variable_name varchar2(20)
Example: SQL> create table test (my_char varchar2(40));<br>Table created.