Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
To Char or Varchar - Tat is the question
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Divers
Thread ID:
00979748
Message ID:
00979907
Vues:
15
Perfect explanation. Thanks!

>>So what are the advantages/disadvantages of using either one?
>
>The answer could be extensive. A simple overview - if you have a character value that is of a fixed consistent length, then you could use char eg., you have an 8 character alphanumeric stock code.
>
>You could have a surname column that might have to handle surname's with a length upto 40 chars. If you wright a 3 char surname, you are wasting 37 chars in a char column. So, it might make sense to use varchar in this case - character data of a varying length.
>
>The main advantage of varchar is that it saves space. The main disadvantage of varchar is that if you update a varchar column with a new value that is larger than the old, without getting into the internals of SQL server, SQL server has to effectively make space in the record for the extra information to be written to the existing varchar column. This can result in data having to be "shunted" along the record and/or written to a different page. Therefore, the biggest disadvantage in this scenario is the performance hit in having to manage the allocation of more space for the increased size of the new content to the varchar column in question. Therefore, record updates can take longer to process.
>
>With a char column, the space is already allocated.
>
>I am over simplifying this but you should get a feel for what is happening.
>
>HTH
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform