Churchill27
03-03-2002, 20:05
Hi,
ich möchte eine Tabelle anlegen, die sowohl blob als auch char Felder beinhaltet. Wenn ich jetzt zwei char Felder definiere und danach ein blob Feld, werden die char Felder zu varchar Felder konvertiert.
Warum, und wie kann ich das Problem lösen ?
Churchill27
03-03-2002, 20:12
Wen es interessiert, habe das Problem selber gefunden:
In some cases, MySQL silently changes a column specification from that given in a CREATE TABLE statement. (This may also occur with ALTER TABLE.):
VARCHAR columns with a length less than four are changed to CHAR.
If any column in a table has a variable length, the entire row is variable-length as a result. Therefore, if a table contains any variable-length columns (VARCHAR, TEXT, or BLOB), all CHAR columns longer than three characters are changed to VARCHAR columns. This doesn't affect how you use the columns in any way; in MySQL, VARCHAR is just a different way to store characters. MySQL performs this conversion because it saves space and makes table operations faster. See section 7 MySQL Table Types.
in MySQL, VARCHAR is just a different way to store characters. MySQL performs this conversion because it saves space and makes table operations faster. See section 7 MySQL Table Types.
Stimmt nicht ganz ... zumindest das mit dem Platz sparen - ein Varchar braucht immer soviel Bytes wie der Inhalt der Spalte in der entsprechenden Zeile plus eins (für das NULL-Byte, das das String-Ende anzeigt)
Aber was soll man machen.
Jetzt weiß ich wenigstens, warum ich noch nie CHAR-Felder in mySQL gesehen habe. :)
schmalle
04-03-2002, 09:46
Original geschrieben von Titus
[QUOTE]Jetzt weiß ich wenigstens, warum ich noch nie CHAR-Felder in mySQL gesehen habe. :)
willst du mal meine zugangsdaten haben? :D bei mir gibt es sowas
Raphael 69
04-03-2002, 10:12
Na wunderbar.
Jetzt weiß ich endlich warum ich ständig CHAR sehe wo ich eigentlich VARCHAR "befohlen" habe :lol