Hi ,
What is the diff within Char and Varchar ? If define Char(10) in TableA
and this field is store the State code and the length is a non standard. User
can key in the length from 1 to 10.
Understand that I should define this field as VarChar(10) because is it a
no fixed length. But I don't really undertand what is the diff between this
two datatype in the backend structure ? It save the space ?
Travis Tan
In the backend char(10) is always stored as 10 characters (bytes), which
can give you problems when doing string comparisons because the string
will be padded with trailing spaces.
Varchar(10) will store a 32 bit integer (4 bytes) at the front of the
field to indicate the field length, followed by the actual number of
characters in the string.
So if you store a 2 character string in a varchar(10) it will use 6
bytes storage, if you store a 10 character string it will store 14
bytes.
HTH
Regards
Darren Gosbell [MCSD]
<dgosbell_at_yahoo_dot_com>
Blog: http://www.geekswithblogs.net/darrengosbell
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment