tags:

views:

55

answers:

2

What is the Difference between varchar and varchar2 in SQL. Please explain in detail with some good example.

A: 

they behave the same, though varchar2 is recommended:

Currently VARCHAR behaves exactly the same as VARCHAR2. However, this type should not be used as it is reserved for future usage.

Source

GSto
+3  A: 

Varchar2 is specific to Oracle.

The most significant nonstandard behavior of varchar2 is that an empty string ('') is the same as null.

In standard SQL, null is not the same as any string literal, not even the empty string.

Bill Karwin
+1 Probably worth mentioning that in Oracle, a condition testing whether `Field = ''` always evaluates as NULL (ie. never true), even if `Field` is '' (ie. NULL).
Mark Bannister
@Mark: Thanks, that's a good point. Whereas in standard SQL, `Field = ''` can be true.
Bill Karwin