What is the difference between varchar and varchar2 in Oracle?

In Oracle, both VARCHAR and VARCHAR2 are datatypes used to store variable-length character strings, but there is a slight difference between them.

The main difference between VARCHAR and VARCHAR2 is that VARCHAR can store up to 2000 data, while VARCHAR2 can store up to 4000 data. This means that VARCHAR2 is capable of storing more characters than VARCHAR.

Another difference is that when you insert a value into a VARCHAR column that exceeds its maximum length, the value will be truncated to the full length. While inserting a value into a VARCHAR2 column that exceeds its maximum length, it will raise an error.

Lastly, in some cases, VARCHAR has different behaviour when it comes to empty strings and null values: when you insert an empty string into a VARCHAR column, it is treated as a null value, while when inserting an empty string into a VARCHAR2 column, it is treated as an empty string.

In general, using VARCHAR2 instead of VARCHAR is recommended, as it has a higher maximum length and better behaviour when it comes to empty strings and null values.

You should also note that VARCHAR datatype is no longer supported starting from Oracle 12c Release 2.