Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Char Versus Varchar2

Status
Not open for further replies.

zik

Technical User
Jan 23, 2006
28
HR
During a conversation with a coworker, I was told that it is BETTER to use varchar2(1) than to user char1(1).
Can someone please shed some light into this.
Thanks in advance.
zik
 

VARCHAR2 is better than CHAR, storage-wise because no space will be padded in varchar2 when full lenght is not utilized, but VARCHAR2(1) and CHAR(1) will always be the same because no space will be padded since you only have two value options for char, a single character value and a null.
Robbie

"The rule is, not to besiege walled cities if it can possibly be avoided" -- Art of War
 
Thank you rcurva!
That was precisely my argument.
Thanks for reimforcing that.
zik
 
Not strictly true. Varchar2(1) will use more space than char(1), since it is variable length Oracle will store the length in the row header in 3 bytes, instead of the 1 byte row header used by char(1). So varchar2 will be stored in minimum of 3 bytes, as apposed to the 2 used by char. However, Oracle are phasing out the use of char & recommend that varchar2 is used.

uepjp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top