[KLUG Members] mysql

Adam Tauno Williams members@kalamazoolinux.org
Mon, 25 Aug 2003 11:05:30 -0400


> When I create this table:
> create table svcticket
> (
> id bigint unsigned not null auto_increment primary key,
> sdescription char(255) not null,
> reqdate date,
> assingdate date,
> closedate date,
> reqby char(30) not null,
> assignby char(30),
> assignto char(30),
> wrkstn char(15),
> user char(30),
> ldescription text,
> closeby char(30)
> );
> why does it change the columns from char to varchar? Like this:
> mysql> describe svcticket;
> +--------------+---------------------+------+-----+---------+----------------+
> | Field        | Type                | Null | Key | Default | Extra         
> |
> +--------------+---------------------+------+-----+---------+----------------+
> | id           | bigint(20) unsigned |      | PRI | NULL    | auto_increment
> |
> | sdescription | varchar(255)        |      |     |         |               
> |
> | reqdate      | date                | YES  |     | NULL    |               
> |
> | assingdate   | date                | YES  |     | NULL    |               
> |
> | closedate    | date                | YES  |     | NULL    |               
> |
> | reqby        | varchar(30)         |      |     |         |               
> |
> | assignby     | varchar(30)         | YES  |     | NULL    |               
> |
> | assignto     | varchar(30)         | YES  |     | NULL    |               
> |
> | wrkstn       | varchar(15)         | YES  |     | NULL    |               
> |
> | user         | varchar(30)         | YES  |     | NULL    |               
> |
> | ldescription | text                | YES  |     | NULL    |               
> |
> | closeby      | varchar(30)         | YES  |     | NULL    |               
> |
> +--------------+---------------------+------+-----+---------+----------------+

It is a mysql-ism.  Various char types cannot be mixed in the same row,  all
static length char fields are silently converted to variable length char fields
in any variable length char fields are present.  (Your text field is a variable
length char type). This is something the MySQL people call a feature.  It
probably doesn't hurt you unless you need fixed length strings.