char length
am 22.02.2005 04:24:19 von wyght
I am building a simple MySQL DB, I would like to have a Char of UNKNOWN
size. I do not know what to do about this. The Char could be as small as 100
or as large as 2,400. Is there a method of making a Variable size of a char?
I
thanks
Totus possum, totum Deum.
Totus ero, totum meum.
WSW
--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org
Re: char length
am 22.02.2005 04:58:37 von Petr Vileta
If your char field will be all time less then 256 characters you can to use
"varchar" type. If will be grater then 255 you can use "text" or "longtext"
type.
Petr Vileta, Czech republic
----- Original Message -----
From: "Warren"
To:
Sent: Tuesday, February 22, 2005 4:24 AM
Subject: char length
> I am building a simple MySQL DB, I would like to have a Char of UNKNOWN
> size. I do not know what to do about this. The Char could be as small as
100
> or as large as 2,400. Is there a method of making a Variable size of a
char?
> I
>
> thanks
>
> Totus possum, totum Deum.
> Totus ero, totum meum.
> WSW
>
>
>
>
> --
> MySQL Windows Mailing List
> For list archives: http://lists.mysql.com/win32
> To unsubscribe: http://lists.mysql.com/win32?unsub=petr@practisoft.cz
>
--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org
RE: char length
am 22.02.2005 05:29:46 von wyght
------=_NextPart_000_0001_01C5185C.78641550
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Thanks for your help, I have an additional question
So if my CHAR may or may not be over 255 would I use text? This will not be
a huge DB therefore it will not use GBs of room if I use a CHAR to large for
many of the instances. Still I would like to do this the most intelligent
way I can.
I think there will only be about 1,900 different instances of the CHAR in
the DB some being smaller than 255, some being larger than 2,300.
Totus possum, totum Deum.
Totus ero, totum meum.
WSW
------=_NextPart_000_0001_01C5185C.78641550
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment
From: "Petr Vileta"
To:
References: <000001c5188d$ffd14f90$6400a8c0@clone>
Subject: Re: char length
Date: Mon, 21 Feb 2005 20:58:37 -0700
Message-ID: <000901c51892$cb27c440$6401a8c0@ns>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4807.1700
List-Help:
List-Unsubscribe:
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-Virus-Checked: Checked
X-Relay-IP: 213.136.52.31
X-SPF-Debug: implemented=no,result=pass
X-Spam-Score: -0.985 () BAYES_00,DNS_FROM_RFC_POST
X-Tracking-ID: j1M3wvCY089814
X-Scanned-By: MIMEDefang 2.45
X-AntiSpam: Checked for restricted content by Gordano's AntiSpam Software
Importance: Normal
If your char field will be all time less then 256 characters you can to use
"varchar" type. If will be grater then 255 you can use "text" or "longtext"
type.
Petr Vileta, Czech republic
----- Original Message -----
From: "Warren"
To:
Sent: Tuesday, February 22, 2005 4:24 AM
Subject: char length
> I am building a simple MySQL DB, I would like to have a Char of UNKNOWN
> size. I do not know what to do about this. The Char could be as small as
100
> or as large as 2,400. Is there a method of making a Variable size of a
char?
> I
>
> thanks
>
> Totus possum, totum Deum.
> Totus ero, totum meum.
> WSW
>
>
>
>
> --
> MySQL Windows Mailing List
> For list archives: http://lists.mysql.com/win32
> To unsubscribe: http://lists.mysql.com/win32?unsub=petr@practisoft.cz
>
--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=warren@wyght.com
------=_NextPart_000_0001_01C5185C.78641550
Content-Type: text/plain; charset=us-ascii
--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org
------=_NextPart_000_0001_01C5185C.78641550--
Re: char length
am 22.02.2005 10:11:20 von Mike Rains
If your maximum length string is 2,400 characters long, you should be
using the TEXT data type, and here's why:
CHAR has a fixed-length of whatever you tell it, up to the upper limit
of 255 characters; it has no length byte(s) to describe how long that
particular piece of data is, and is right-padded with spaces to fill
out the string.
Both VARCHAR and TINYTEXT use a single byte length prefix (remember, a
byte can hold a single number from 0 to 255, which is x00 to xFF in
hexidecimal); thus, they can hold up to 255 characters.
TEXT uses a 2-byte length prefix (x0000 to xFFFF in hex, which
translates into 0 to 65,535 in decimal); thus, it can hold up to 64KB.
MEDIUMTEXT uses a 3-byte length prefix (x000000 to xFFFFFF hex, 0 to
16,777,215 deximal); thus, it can hold up to 16MB.
LONGTEXT uses a 4-bytes length prefix (x00000000 to xFFFFFFFF hex, 0
to 4,294,967,295 decimal); thus, it can hold up to 4GB.
Suppose you declare your field a LONGTEXT; storing the string 'A'
would require 5 bytes, 4 for the length bytes (x00 00 00 01) and one
for the 'A' (x41). Storing that same 'A' in a CHAR(255) field would
require 255 bytes, with the first byte being the 'A' (x41) and the
rest padded out with spaces (x20 times 254).
Since you said that your maximum string length can be as large as
2,400 characters, you can't use CHAR, nor can you use VARCHAR (or
TINYTEXT), because their maximum lengths are only 255 characters.You
can use TEXT, whose maximum length is 65,535 characters; you could
also use MEDIUMTEXT or LONGTEXT too, but you don't need to waste the
extra byte or two per string for each entry, if you know your field
won't go over 64KB.
Reference:
http://dev.mysql.com/doc/mysql/en/string-type-overview.html
--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org