Home > Ask the Oracle Experts > Questions & Answers
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

VARCHAR2 vs. VARCHAR vs. CHAR

Brian Peasland EXPERT RESPONSE FROM: Brian Peasland

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site
>
QUESTION POSED ON: 29 January 2003
Regarding "Why does Oracle recommend using VARCHAR2 instead of VARCHAR datatypes?", I challenge the answer given. I have worked with Oracle 5, 6, 7, 7.2, 8.0, and 8.1, and although the early versions of Oracle are hard to remember, it has always been true that a zero-length string and NULL are treated the same for the varying-length character data type (VARCHAR2). Perhaps you had the "CHAR" type in mind, which is a fixed-length character data type; here an empty string would be padded with blanks to the declared length, and was definitely not the same as NULL.

>
EXPERT RESPONSE

You are correct, to a point. I had CHAR in mind, instead of VARCHAR2. Thanks for pointing that out.

But Note:1011340.6 on Metalink does state that the the behavior of zero-length strings and NULLS changed by Oracle 7.1.3 all the way through Oracle 8.1.7. And if you do some further digging, how Oracle handles zero-length strings really only applies to inserting the data. Try issuing the following queries (I tested this in Oracle 8, 8i, and 9i):

SELECT * FROM my_table WHERE column_name IS NULL;
SELECT * FROM my_table WHERE column_name='';
They will return two different results! So not all handling of zero length strings is the same. I recall reading somewhere along the line that Oracle Corp. was going to change this behavior in 9i. Apparently, my information was in error. Thanks for pointing it out!

For More Information


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts