Hi,
I am new here. When shall I use char and when shalll I use varchar?
Thanks!!!
MichaelHi Michael,
Some suggestions
When to use CHAR data type
1. When more than 80% of the field will be filled with data
2. If the column is a key column
When to use VARCHAR datatype
1. When 50% of the field will be empty for most of the records. This will
help you to save the storage space.
2. When the field may have null values.
"Michael" <michaelnx@.gmail.com> wrote in message
news:1176131166.739692.126160@.y66g2000hsf.googlegroups.com...
> Hi,
> I am new here. When shall I use char and when shalll I use varchar?
> Thanks!!!
> Michael
>|||On Apr 9, 11:20 am, "Shri.DBA" <tbalajipra...@.hotmail.com> wrote:
> Hi Michael,
> Some suggestions
> When to use CHAR data type
> 1. When more than 80% of the field will be filled with data
> 2. If the column is a key column
> When to use VARCHAR datatype
> 1. When 50% of the field will be empty for most of the records. This will
> help you to save the storage space.
> 2. When the field may have null values.
> "Michael" <michae...@.gmail.com> wrote in message
> news:1176131166.739692.126160@.y66g2000hsf.googlegroups.com...
>
> > Hi,
> > I am new here. When shall I use char and when shalll I use varchar?
> > Thanks!!!
> > Michael- Hide quoted text -
> - Show quoted text -
Thanks a lot! What's the major difference except storage saving?
Thanks,
Michael|||> Thanks a lot! What's the major difference except storage saving?
Each varchar column has an overhead of 2 byte, compared to the same char column.
As you update the row, if the row size increases, and the row no longer fit on the page, the row
will move to some other page (if a heap) with forwarding pointers from the non-clustered indexes, or
if a clustered table or inside a non-clustered index, you will end up with page splits.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Michael" <michaelnx@.gmail.com> wrote in message
news:1176132319.713673.278660@.e65g2000hsc.googlegroups.com...
> On Apr 9, 11:20 am, "Shri.DBA" <tbalajipra...@.hotmail.com> wrote:
>> Hi Michael,
>> Some suggestions
>> When to use CHAR data type
>> 1. When more than 80% of the field will be filled with data
>> 2. If the column is a key column
>> When to use VARCHAR datatype
>> 1. When 50% of the field will be empty for most of the records. This will
>> help you to save the storage space.
>> 2. When the field may have null values.
>> "Michael" <michae...@.gmail.com> wrote in message
>> news:1176131166.739692.126160@.y66g2000hsf.googlegroups.com...
>>
>> > Hi,
>> > I am new here. When shall I use char and when shalll I use varchar?
>> > Thanks!!!
>> > Michael- Hide quoted text -
>> - Show quoted text -
> Thanks a lot! What's the major difference except storage saving?
> Thanks,
> Michael
>|||On Apr 9, 11:30 am, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
> > Thanks a lot! What's the major difference except storage saving?
> Each varchar column has an overhead of 2 byte, compared to the same char column.
> As you update the row, if the row size increases, and the row no longer fit on the page, the row
> will move to some other page (if a heap) with forwarding pointers from the non-clustered indexes, or
> if a clustered table or inside a non-clustered index, you will end up with page splits.
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/tibor_karaszi
> "Michael" <michae...@.gmail.com> wrote in message
> news:1176132319.713673.278660@.e65g2000hsc.googlegroups.com...
>
> > On Apr 9, 11:20 am, "Shri.DBA" <tbalajipra...@.hotmail.com> wrote:
> >> Hi Michael,
> >> Some suggestions
> >> When to use CHAR data type
> >> 1. When more than 80% of the field will be filled with data
> >> 2. If the column is a key column
> >> When to use VARCHAR datatype
> >> 1. When 50% of the field will be empty for most of the records. This will
> >> help you to save the storage space.
> >> 2. When the field may have null values.
> >> "Michael" <michae...@.gmail.com> wrote in message
> >>news:1176131166.739692.126160@.y66g2000hsf.googlegroups.com...
> >> > Hi,
> >> > I am new here. When shall I use char and when shalll I use varchar?
> >> > Thanks!!!
> >> > Michael- Hide quoted text -
> >> - Show quoted text -
> > Thanks a lot! What's the major difference except storage saving?
> > Thanks,
> > Michael- Hide quoted text -
> - Show quoted text -
Thank you very much!! Michael
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment