You can store string with 3 characters in a char(5) or even char(50); If you have a string that can have between 1 and 50 characters you can use varchar. If the size is always close to 50 I would use char(50).
But in my opinion a varchar(5) doesn't make much sense since it doesn't take up much space anyway. I wouldn't worry about optimizing in small databases. But it's always good practice to create every table in a sensible structure. ----- Original Message ----- From: "Lisi" <[EMAIL PROTECTED]> To: "Remco Oosten" <[EMAIL PROTECTED]>; "PHP-DB" <[EMAIL PROTECTED]> Sent: Monday, April 08, 2002 11:33 AM Subject: Re: [PHP-DB] Error creating new table > Worked like a charm, thanks. > > How do I avoid varchar if I the size of the text will vary with each entry? > > It's going to be a pretty small database anyway so I'm not that worried, > but how often do I optimize the table to avoid fragmentation? > > -Lisi > > At 10:29 AM 4/8/02 +0200, you wrote: > >I don't think you can use text(50), > > > >It should be one of the following tinytext, mediumtext or text > >Or you should use char(50). > > > >I would try to avoid using varchar() it fragments the database. > > > >Remco > > > >----- Original Message ----- > >From: "Lisi" <[EMAIL PROTECTED]> > >To: <[EMAIL PROTECTED]> > >Sent: Monday, April 08, 2002 11:11 AM > >Subject: [PHP-DB] Error creating new table > > > > > > > I am trying to create the following table using PHPMyAdmin: > > > > > > CREATE TABLE IF NOT EXISTS ayny( > > > organization varchar(50) NOT NULL, > > > subtitle varchar(50) NOT NULL, > > > img varchar(20) NOT NULL, > > > width varchar(5), > > > height varchar(5), > > > link varchar(30) NOT NULL, > > > maintext text(50) NOT NULL, > > > boxtext text(50) NOT NULL, > > > ID INT(9) NOT NULL AUTO_INCREMENT, > > > PRIMARY KEY(ID) > > > ); > > > > > > But I keep getting the following error: > > > > > > MySQL said: You have an error in your SQL syntax near '(50) NOT NULL, > > > boxtext text(50) NOT NULL, ID INT(9) NOT NULL AUTO_INCREMENT,' at line 8 > > > > > > Any ideas what I'\m doing wrong? > > > > > > TIA, > > > > > > -Lisi > > > > > > > > > -- > > > PHP Database Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > >-- > >PHP Database Mailing List (http://www.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php