/ Forside / Teknologi / Udvikling / SQL / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
SQL
#NavnPoint
pmbruun 1704
niller 962
fehaar 730
Interkril.. 701
ellebye 510
pawel 510
rpje 405
pete 350
gibson 320
10  smorch 260
mysql datatype text
Fra : Thomas D


Dato : 27-06-03 15:49

hej,

udfra hvad jeg kan forstå på
http://www.mysql.com/doc/en/Storage_requirements.html så er datatypen "TEXT"
i mysql af en variabel længde.
Altså man kan sætte den til en længde lige som fx varchar(255)

men jeg kan ikke få mysql til at acceptere text(2048)

er det mig der er gal på den?

mvh
Thomas



 
 
Morten Wulff (27-06-2003)
Kommentar
Fra : Morten Wulff


Dato : 27-06-03 18:07

On Fri, 27 Jun 2003 16:48:52 +0200, Thomas D <dinadur@hotmail.com> wrote:

> udfra hvad jeg kan forstå på
> http://www.mysql.com/doc/en/Storage_requirements.html så er datatypen
> "TEXT"
> i mysql af en variabel længde.

Den kan indeholde en variabel mængde data; op til 65535 bytes.

> Altså man kan sætte den til en længde lige som fx varchar(255)

Nej.

> men jeg kan ikke få mysql til at acceptere text(2048)

Nej, ved at angive TEXT typen fortæller du MySQL at det givne felt vil
kunne indeholde op til 65535 bytes. Kig evt. på:
http://www.mysql.com/doc/en/String_types.html (og afsnit 6.2.3.2).


mvh,

Morten Wulff


--
Self Injury Information and Support: www.psyke.org

"Let's say the docs present a simplified view of reality..." Larry Wall

Thomas D (27-06-2003)
Kommentar
Fra : Thomas D


Dato : 27-06-03 19:24

> > udfra hvad jeg kan forstå på
> > http://www.mysql.com/doc/en/Storage_requirements.html så er datatypen
> > "TEXT"
> > i mysql af en variabel længde.
>
> Den kan indeholde en variabel mængde data; op til 65535 bytes.
>
> > Altså man kan sætte den til en længde lige som fx varchar(255)
>
> Nej.
>
> > men jeg kan ikke få mysql til at acceptere text(2048)
>
> Nej, ved at angive TEXT typen fortæller du MySQL at det givne felt vil
> kunne indeholde op til 65535 bytes. Kig evt. på:
> http://www.mysql.com/doc/en/String_types.html (og afsnit 6.2.3.2).

Har jeg læst men hvordan forstår du så dette:
"VARCHAR and the BLOB and TEXT types are variable-length types, for which
the storage requirements depend on the actual length of column values
(represented by L in the preceding table), rather than on the type's maximum
possible size. For example, a VARCHAR(10) column can hold a string with a
maximum length of 10 characters. The actual storage required is the length
of the string (L), plus 1 byte to record the length of the string. For the
string 'abcd', L is 4 and the storage requirement is 5 bytes.
The BLOB and TEXT types require 1, 2, 3, or 4 bytes to record the length of
the column value, depending on the maximum possible length of the type. See
section 6.2.3.2 The BLOB and TEXT Types. "


taget fra http://www.mysql.com/doc/en/Storage_requirements.html

Mvh
Thomas



Morten Wulff (27-06-2003)
Kommentar
Fra : Morten Wulff


Dato : 27-06-03 19:44

On Fri, 27 Jun 2003 20:23:53 +0200, Thomas D <dinadur@hotmail.com> wrote:

>> Nej, ved at angive TEXT typen fortæller du MySQL at det givne felt vil
>> kunne indeholde op til 65535 bytes. Kig evt. på:
>> http://www.mysql.com/doc/en/String_types.html (og afsnit 6.2.3.2).
>
> Har jeg læst men hvordan forstår du så dette:
> "VARCHAR and the BLOB and TEXT types are variable-length types, for which
> the storage requirements depend on the actual length of column values
> (represented by L in the preceding table), rather than on the type's
> maximum
> possible size. For example, a VARCHAR(10) column can hold a string with a
> maximum length of 10 characters. The actual storage required is the
> length
> of the string (L), plus 1 byte to record the length of the string.

Hvis jeg har et varcher(16) felt og gemmer strengen 'morten' i det, vil det
fylde 7 bytes: 6 bytes til strengen 'morten' og 1 byte til at fortælle at
feltet indeholder 6 bytes (jeg ser lige bort fra unicode...)

> For the
> string 'abcd', L is 4 and the storage requirement is 5 bytes.
> The BLOB and TEXT types require 1, 2, 3, or 4 bytes to record the length
> of
> the column value, depending on the maximum possible length of the type.

Gemmer jeg strengen 'morten' i et TEXT felt vil det fylde 8 bytes: 6 bytes
til strengen 'morten' og 2 bytes til at fortælle at feltet indeholder 6
bytes (TEXT kan indeholde 2^(2^2)-1 bytes). Bruger jeg LONGTEXT vil der gå
6 bytes til strengen og 4 bytes til at beskrive længden (LONGTEXT kan
indeholde 2^(2^4)-1 bytes).

> taget fra http://www.mysql.com/doc/en/Storage_requirements.html

Se tabellen på: http://www.mysql.com/doc/en/String_types.html


mvh,

Morten Wulff



--
Self Injury Information and Support: www.psyke.org

"Let's say the docs present a simplified view of reality..." Larry Wall

Thomas D (28-06-2003)
Kommentar
Fra : Thomas D


Dato : 28-06-03 00:29


> Hvis jeg har et varcher(16) felt og gemmer strengen 'morten' i det, vil
det
> fylde 7 bytes: 6 bytes til strengen 'morten' og 1 byte til at fortælle at
> feltet indeholder 6 bytes (jeg ser lige bort fra unicode...)
>

ok


> Gemmer jeg strengen 'morten' i et TEXT felt vil det fylde 8 bytes: 6 bytes
> til strengen 'morten' og 2 bytes til at fortælle at feltet indeholder 6
> bytes (TEXT kan indeholde 2^(2^2)-1 bytes). Bruger jeg LONGTEXT vil der gå
> 6 bytes til strengen og 4 bytes til at beskrive længden (LONGTEXT kan
> indeholde 2^(2^4)-1 bytes).

ok


> > taget fra http://www.mysql.com/doc/en/Storage_requirements.html
>
> Se tabellen på: http://www.mysql.com/doc/en/String_types.html
>

hermed gjort

Mvh
Thomas



Peter Brodersen (27-06-2003)
Kommentar
Fra : Peter Brodersen


Dato : 27-06-03 18:10

On Fri, 27 Jun 2003 16:48:52 +0200, "Thomas D" <dinadur@hotmail.com>
wrote:

>udfra hvad jeg kan forstå på
>http://www.mysql.com/doc/en/Storage_requirements.html så er datatypen "TEXT"
>i mysql af en variabel længde.
>Altså man kan sætte den til en længde lige som fx varchar(255)
>
>men jeg kan ikke få mysql til at acceptere text(2048)

Nej, text(n) virker desværre ikke - en gammel MySQL-ODBC-klient har
samme problem, når man fx eksporterer fra MS Access.

Du bør nøjes med at bruge TEXT, og så lade MySQL bekymre sig om
datapladsen.

--
- Peter Brodersen

Thomas D (27-06-2003)
Kommentar
Fra : Thomas D


Dato : 27-06-03 19:24

> Nej, text(n) virker desværre ikke - en gammel MySQL-ODBC-klient har
> samme problem, når man fx eksporterer fra MS Access.
>
> Du bør nøjes med at bruge TEXT, og så lade MySQL bekymre sig om
> datapladsen.

OK.
Hvordan skal dette så forstås:
"VARCHAR and the BLOB and TEXT types are variable-length types, for which
the storage requirements depend on the actual length of column values
(represented by L in the preceding table), rather than on the type's maximum
possible size."
?

taget fra: http://www.mysql.com/doc/en/Storage_requirements.html



Søg
Reklame
Statistik
Spørgsmål : 177516
Tips : 31968
Nyheder : 719565
Indlæg : 6408629
Brugere : 218887

Månedens bedste
Årets bedste
Sidste års bedste