difference between varchar and varchar2?
+7
A:
As for now, they are synonyms.
VARCHAR
is reserved by Oracle
to support distinction between NULL
and empty string in future, as ANSI
standard prescribes.
VARCHAR2
does not distinguish between a NULL
and empty string, and never will.
If you rely on empty string and NULL
being the same thing, you should use VARCHAR2
.
Quassnoi
2009-07-23 11:41:26
Hadn't heard that rationale before, that's useful. Thanks.For the record, it is still totally ridiculous that the main character type in Oracle is "varchar2". Doesn't that strike anybody else as a terrible kludge? Seems like how I would have solved some problem in my first week of learning to program.
Ian Varley
2010-05-31 15:14:27
@Ian: main type is `VARCHAR2` because currently there is no type that behaves like `VARCHAR` should. In fact, you should not use `VARCHAR` at all until it's implemented properly.
Quassnoi
2010-05-31 15:28:35
Thanks, @Quassnoi. So I guess the stupid part is that Oracle doesn't have a proper VARCHAR like every other database, then? There's something stupid going on here, I'm sure of it ... :)
Ian Varley
2010-06-01 17:48:52
@Ian: when Oracle was being developed, there were no standards. By the time the standards emerged it already had a burden of legacy apps. We all know how it happens.
Quassnoi
2010-06-01 18:30:53
Yeah, I've been there. :)
Ian Varley
2010-06-01 19:55:01
A:
For now, they are exactly the same. It's a pre-reserved variable that may be used later in the future.
Jovan
2009-07-23 11:41:48
VARCHAR being the pre-reserved variable, correct?So it is best to use VARCHAR2.
marked
2010-10-29 18:36:29
+11
A:
Currently VARCHAR behaves exactly the same as VARCHAR2. However, this type should not be used as it is reserved for future usage.
Taken from: Difference Between CHAR, VARCHAR, VARCHAR2
Brian
2009-07-23 11:43:16