could u tell me the differences between data types of text, char and varchar?
i focus on size of each type used.
thanks
differences between data types of text, char and varchar
Moderator: General Moderators
-
aaaphp000000
- Forum Newbie
- Posts: 22
- Joined: Mon Aug 29, 2005 5:39 am
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
http://dev.mysql.com/doc/mysql/en/char.html
Basically char is fixed length given by "char(x)" where x is the length of the string between 0 and 255. It uses x+2 bytes of storage if I remember correctly. If the string entered is shorter than x mysql adds spaces to ensure consistency in the number of bytes used.
varchar is variable length up to a maximum length of x "varchar(x)". Until MySQL 5 this was 0 to 255 too. In MySQL 5 it goes into 65K in length.
text is for longer extracts of text. It is all covered in the manual though
Basically char is fixed length given by "char(x)" where x is the length of the string between 0 and 255. It uses x+2 bytes of storage if I remember correctly. If the string entered is shorter than x mysql adds spaces to ensure consistency in the number of bytes used.
varchar is variable length up to a maximum length of x "varchar(x)". Until MySQL 5 this was 0 to 255 too. In MySQL 5 it goes into 65K in length.
text is for longer extracts of text. It is all covered in the manual though
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
-
aaaphp000000
- Forum Newbie
- Posts: 22
- Joined: Mon Aug 29, 2005 5:39 am
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact: