wustenveld schreef op 10 oktober 2002 @ 15:22:
Ik dacht altijd dat het juist een text veld was die standaard alle ruimte inneemt. Dus een textveld van 20 neemt 20 bytes in beslag. En een varchar van 20 neemt 0 bytes in als er niks in staat, en 10 bytes als er 10 tekens in staan.
Althans dat had ik een keer gelezen in een mySQL handleiding
Dat zou wat wezen zeg.
Textvelden van 20 bestaan trouwens niet

Maar GoT werkt met textvelden van 64KB en _gelukkig_ nemen niet alle messages 64KB in

Dan zou de database wel even een *kuch* stukje groter zijn... (gemiddelde is ergens in de buurt van 1a2KB ofzo).
Juist een textveld/blob is volledig variabel in lengte (kwa opslag).
Varchars in bijv interbase zijn niet variabel in lengte (kwa opslag) en het enige verschil met chars is dat er geen spaties aan toegevoegd worden bij de output.
Verwijderd schreef op 10 oktober 2002 @ 15:26:
Heeft een varchar niet een maximale grootte van 256 characters? En een blob/text (is volgens mij synoniem) in principe onbeperkt? Overigens staat dit soort info allemaal in de documentatie op mysql.com.
Nee, dat geldt alleen voor mysql.
En mysql is gelijk de enige die een dusdanig beperkte lengte kent (bij mijn weten Msql vast ook wel).
Veel databases zitten rond de 8000 of nog groter (64000 bijv).
Postgresql kan zelfs een varchar (MAXINT) aan, ergens rond de 2G dus.
Dat zal in principe voor een varchar ook moeten, maar dat hangt dus af van hoe en wat de implementatie van dat DBMS doet.
Verwijderd schreef op 10 oktober 2002 @ 15:28:
In het kader van RTFM:
In most respects, you can regard a TEXT column as a VARCHAR column that can be as big as you like. Similarly, you can regard a BLOB column as a VARCHAR BINARY column. The differences are:
* You can have indexes on BLOB and TEXT columns with MySQL Version 3.23.2 and newer. Older versions of MySQL did not support this.
* There is no trailing-space removal for BLOB and TEXT columns when values are stored, as there is for VARCHAR columns.
* BLOB and TEXT columns cannot have DEFAULT values.
Zie handleiding op mysql.com dus!
Wat voor mysql geldt geldt niet perse voor anderen. Ik kan zo snel geen zinvolle reden verzinnen voor een index op een text-veld, maar je zou hem idd als primary key kunnen gebruiken.
Blob en Text hebben trouwens wel degelijk default waarde bij mysql, die vult _altijd_ "" of NULL in als je de kolom niet opgeeft

Verwijderd schreef op 10 oktober 2002 @ 15:31:
_kuch_ _kuch_ ff me gelijk halen =)
Values in VARCHAR columns are variable-length strings. You can declare a VARCHAR column to be any length between 1 and 255, just as for CHAR columns.
Geldt dus alleen voor mysql:
SQL defines two primary character types: character(n) and character varying(n), where n is a positive integer. Both of these types can store strings up to n characters in length. An attempt to store a longer string into a column of these types will result in an error, unless the excess characters are all spaces, in which case the string will be truncated to the maximum length. (This somewhat bizarre exception is required by the SQL standard.) If the string to be stored is shorter than the declared length, values of type character will be space-padded; values of type character varying will simply store the shorter string.
Note: Prior to PostgreSQL 7.2, strings that were too long were silently truncated, no error was raised.
The notations char(n) and varchar(n) are aliases for character(n) and character varying(n), respectively. character without length specifier is equivalent to character(1); if character varying is used without length specifier, the type accepts strings of any size. The latter is a PostgreSQL extension.
In addition, PostgreSQL supports the more general text type, which stores strings of any length. Unlike character varying, text does not require an explicit declared upper limit on the size of the string. Although the type text is not in the SQL standard, many other RDBMS packages have it as well.
The storage requirement for data of these types is 4 bytes plus the actual string, and in case of character plus the padding. Long strings will be compressed by the system automatically, so the physical requirement on disk may be less. In any case, the longest possible character string that can be stored is about 1 GB. (The maximum value that will be allowed for n in the data type declaration is less than that. It wouldn't be very useful to change this because with multibyte character encodings the number of characters and bytes can be quite different anyway. If you desire to store long strings with no specific upper limit, use text or character varying without a length specifier, rather than making up an arbitrary length limit.)
Tip: There are no performance differences between these three types, apart from the increased storage size when using the blank-padded type.
Bron:
http://www.postgresql.org...p?datatype-character.html