mfischer Posted October 21, 2003 Share Posted October 21, 2003 Hello, I used the book PHP fast & easy book which had some PHP code for creating tables. THe code worked but mysql seems to change (with no pattern that I can understand varchar to char and visa versa). I have printed out the sql create statement prior to executing it that is built by the PHP code for instance : CREATE TABLE teacher (id char (5) not null,name varchar (40) not null,email varchar (30) null,level varchar (5) null, UNIQUE id(id)) but when I look at the table using the explain command all the fields are defined as varchar. The size of the field and other options I selected are correct. Any ideas? Thanks, Maureen Link to comment https://forums.phpfreaks.com/topic/1204-creating-tables-varchar-and-char-odd-thing-happening/ Share on other sites More sharing options...
yrrahxob Posted November 9, 2003 Share Posted November 9, 2003 I wouldn\'t worry about it. Mysql automatically converts char to vchar if the field is over 3 or 4 bytes long. This is to save disk space for tables having an extremely large number of rows. Imagine a field that took up 500 bytes but only held 25 bytes of data but the table had 10 million records. lots of wasted space there. Link to comment https://forums.phpfreaks.com/topic/1204-creating-tables-varchar-and-char-odd-thing-happening/#findComment-4410 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.