Difference between Varchar and Varchar2
Key Difference: Varchar and Varchar2 are two data-types in Oracle. Varchar stands for variable length character string. They are used to store strings. Varchar2 can store a variable-length character string with an upper limit of 4000 bytes. Varchar is the same as Varchar2. However, it has been scheduled to be redefined in the future, and thus it is not recommended to use Varchar data type in the current scenario.
include("ad4th.php"); ?>Varchar2 stands for variable length character string2. In Oracle, this datatype is used to store a variable length character string. If a table is created with a column defined by a Varchar2 datatype, then in that case one can specify a maximum string length between 1 and 4000 bytes for that particular column. However, if a value exceeding the column’s maximum length is inserted into that column, then in that case the Oracle database generates an error. If a table column is marked as a Varchar2 (data type) with a maximum size of 30 characters. If in a single-byte character set, only 5 characters are defined in that column as a value for a particular row. Then, only 5 characters will be stored.
Varchar is also regarded synonymous with Varchar2. Currently, Varchar behaves exactly the same as Varchar2. However, it is not recommended to use Varchar as this may lead to possible behaviorial changes in the future. Varchar has been used to reserve the space for future usage. Varchar and Varchar2 save space on the table. It is always recommended to use Varchar2 rather than Varchar.
include("ad3rd.php"); ?>Oracle documentation of 10G Release 2 clearly states :
“Do not use the VARCHAR datatype. Use the VARCHAR2 datatype instead. Although the VARCHAR datatype is currently synonymous with VARCHAR2, the VARCHAR datatype is scheduled to be redefined as a separate datatype used for variable-length character strings compared with different comparison semantics.”
Comparison between Varchar and Varchar2:
|
Varchar |
Varchar2 |
Full form |
Variable length character string |
Variable length character string2 |
Definition |
In Oracle, not recommended to be used currently. VARCHAR might be defined as a separate data type for variable-length character strings in the future. |
In Oracle, this datatype is used to store a variable length character string with a maximum of 4000 bytes. |
Max length SQL Bytes / Character |
4000 |
4000 |
Images Courtesy: commons.wikimedia.org
Add new comment