# Mysql so simple question but became headache for me!

**URL:** <https://forum.kirupa.com/t/mysql-so-simple-question-but-became-headache-for-me/269139>\
**Category:** Uncategorized\
**Created:** [August 23, 2008, 8:54am UTC](https://forum.kirupa.com/t/mysql-so-simple-question-but-became-headache-for-me/269139 "2008-08-23T08:54:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![darroosh](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@darroosh](https://forum.kirupa.com/u/darroosh)\
**Post date:** [August 23, 2008, 8:54am UTC](https://forum.kirupa.com/t/mysql-so-simple-question-but-became-headache-for-me/269139/1 "2008-08-23T08:54:32Z")

</div>

Hi all

I have a headache in mysql datatypes , this headache was initiated from some tutorials and increased from the [mysql.com](http://mysql.com) documenation , so please on’t reply with a link to any if them !:}

for the INTEGER datatype i have a problem and for the VARCHAR I have another one :

About the integer :

what is the value of applying a lenght of characters to it ??  
I mean why should i write [COLOR=blue]table\_name int([COLOR=darkred]2[/COLOR]) . [/COLOR][COLOR=black]when I enter a value in the field with more than 2 characters , it’s accepted !! It seems to accept about 10 characters regardless the number i entered ! so what is the value of it ??!![/COLOR]

About the Varchar :  
I think its max length is 255 , but from mysql’s site manual i quoted the folloing code :

> 

The number of bytes required per character varies according to the character set used. For example, if a VARCHAR(100) column in a Cluster table uses the utf8 character set, each character requires 3 bytes storage. This means that each record in such a column takes up 100 × 3 + 1 = 301 bytes for storage, regardless of the length of the string actually stored in any given record. For a VARCHAR(1000) column in a table using the NDBCLUSTER storage engine with the utf8 character set, each record will use 1000 × 3 + 2 = 3002 bytes storage; that is, the column is 1,000 characters wide, each character requires 3 bytes storage, and each record has a 2-byte overhead because 1,000 \>= 256.

How can it holds 1000 character ? Shouln’t it be 255 maximum ??  
and also another small question : As i unerstood , i think that the [COLOR=blue]varchar [/COLOR][COLOR=black]data-type is good as it only uses bytes according to the length of the value entered , but the prevoius quotes says it uses bytes according to the max length regardless the value entered , what’s the matter ?!!! and if so , why use varchar instead of char ?!![/COLOR]
