are you referring to:
---
remember also that a char(x) NULL column is actually a varchar(x) NULL
column. A char column is incapable of holding a null, so behind the scenes
SQL will actually use a varchar field.
---
the way i interpret this is that, char column will be internally stored as
varchar ONLY IF it allows NULL value.
and it seems logical too, because when u declare CHAR(X) NULL, its no longer
fixed length value... it can either contain X characters or 0 characters (or
will it be 1 character ... '\0' ?)
on the other hand, CHAR(X) NOT NULL will be internally stored as char
only... and not as varchar...
is that right?
- Vivek Athalye
http://vna-in-capsule.blogspot.com/
[image: VNA in Capsule]<http://feeds.feedburner.com/%7Er/VnaInCapsule/%7E6/1>
2009/7/10 अमृत राज मिश्रा <misra.arm@...>
>
>
> IMHO, Internally using varchar to implement char will defeat the entire
> purpose of char. Also it seems to a really convoluted design for
> implementing char.
> Regards
> Amrit
>
> 2009/7/10 amey samant <ameyas7@... <ameyas7%40yahoo.com>>
>
>
> >
> >
> > yes that's the general rule. and even i was under the impression that
> char
> > would be faster so should be used when it comes to fixed size data. what
> i
> > was wondering about certain statements that i came across, which claimed
> > that char internally uses varchar. in that case, it would always be
> > beneficial to go with varchar. so just wanted to check if some1 has
> > first-hand figures on performance :)
> > maybe not everything on discussion forums can be relied on ;) or maybe
> they
> > had specific DB in mind.
> >
> > anyways thanks.
> >
> > cheers,
> > amey
> >
> > ________________________________
> > From: ashutosh <ashutosh9910@...
<ashutosh9910%40yahoo.com><ashutosh9910%
> 40yahoo.com>>
> > To: NCST@yahoogroups.com <NCST%40yahoogroups.com> <NCST%
> 40yahoogroups.com>
>
> > Sent: Thursday, 9 July, 2009 10:39:02 PM
> > Subject: [NCST] Re: [query] char vs varchar in DB
> >
> >
> > Here is what I found ....
> >
> > As a general rule, you would pick CHAR if all rows will have the same
> > length and VARCHAR when it is variable length.
> >
> > CHAR is also a bit faster.
> >
> > It actually varies by DB implementation, but generally VARCHAR uses one
> or
> > two more bytes of storage (for length or termination) then CHAR.
> >
> > So (assuming you are using ANSI character set) to store the word "FooBar"
> > in a CHAR(6) is 6 bytes. To store the same word in VARCHAR(10) would be 7
> > bytes. But to store "FooBar" in a CHAR(10) would be 10 bytes.
> >
> > Bottom line is CHAR can be faster and more space efficient for fixed with
> > data than VARCHAR.
> >
> > Thanks
> > Ashutosh
> >
> > --- In NCST@yahoogroups. com, amey samant <ameyas7@... > wrote:
> > >
> > > Hi All,
> > >
> > > i wanted to know if and how does choosing char over varchar impacts the
> > performance.
> > > i have some data which will be fixed size (may contain null). i know
> the
> > ground rule that varchar should be used for variable length data (that
> was
> > back in playschool ... :) jus kiddin)
> > > what i am looking for is if and how much does char can improve
> > performance if we have fixed length data against using varchar for such
> > column.
> > > one simple reason i got is that for varchar, DB will maintain length so
> > there is an overhead of reading length first n then reading tht many
> chars
> > of data. i did browse through lot of discussion forums, some of them
> claim
> > to say that db internally uses varchar even for char. however i really
> doubt
> > if thats the case for all DB. heres one such thread
> > > http://sql-server- performance. com/Community/ forums/p/ 4260/28443.
> > aspx
> > >
> > >
> > > im sure many of us have already gone through this ... some might have
> > even designed their own DB ;)
> > > any inputs are welcome. if you have inputs specific to sybase or MS SQL
> > sever, that will be gr8.
> > > thanks.
> > >
> > >
> > > regards
> > > amey
> > >
> > > Be the change you wish to see in others.
> > > - Mahatma Gandhi
> > >
> > >
> > > blogspot me at-: http://ameyas7. blogspot. com
> > >
> > >
> > >
> > > Looking for local information? Find it on Yahoo! Local
> http://in.local.
> > yahoo.com/
> > >
> > > [Non-text portions of this message have been removed]
> > >
> >
> > Yahoo! recommends that you upgrade to the new and safer Internet Explorer
> > 8. http://downloads.yahoo.com/in/internetexplorer/
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
>
> --
> मंगल भवन, अमंगल हारी !!
>
> [Non-text portions of this message have been removed]
>
>
>
[Non-text portions of this message have been removed]