10

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

1

3 Answers 3

14

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.

Sign up to request clarification or add additional context in comments.

2 Comments

+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: Thanks, that's a good point. Whereas in standard SQL, Field = '' can be true.
2

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

Comments

0

Leigh Riffel on the DBA StackExchange gives the most detailed and precise overview I have read on the difference between VARCHAR and VARCHAR2: https://dba.stackexchange.com/a/1303

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.