alter table ( varchar > char )

alter table ( varchar > char )

am 13.07.2003 17:04:36 von cyril

------=_NextPart_000_0005_01C34960.D6792EE0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello,

I'm running mysql 4.0.12, and I would like change a varchar in a char =
field, nevertheless it means have a bug.
*****
mysql> alter table livredor change date date char(250) not null;
Query OK, 23 rows affected (0.00 sec)
Records: 23 Duplicates: 0 Warnings: 0

mysql> describe livredor;
+-------------+--------------+------+-----+---------+------- ---------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+------- ---------+
| code | int(11) | | PRI | NULL | auto_increment |
| date | varchar(250) | | | | |
| nom | varchar(50) | YES | | NULL | |
| email | varchar(50) | YES | | NULL | |
| commentaire | blob | YES | | NULL | |
+-------------+--------------+------+-----+---------+------- ---------+
5 rows in set (0.01 sec)

mysql>
****

My field "date" is always varchar and not char.

What can I do ?

Best regards,
------=_NextPart_000_0005_01C34960.D6792EE0--

Re: alter table ( varchar > char )

am 13.07.2003 17:35:17 von Fred van Engen

On Sun, Jul 13, 2003 at 05:04:36PM +0200, Cyril [Aceboard] wrote:
> I'm running mysql 4.0.12, and I would like change a varchar in a char field, nevertheless it means have a bug.
> *****
> mysql> alter table livredor change date date char(250) not null;
> Query OK, 23 rows affected (0.00 sec)
> Records: 23 Duplicates: 0 Warnings: 0
>
> mysql> describe livredor;
> +-------------+--------------+------+-----+---------+------- ---------+
> | Field | Type | Null | Key | Default | Extra |
> +-------------+--------------+------+-----+---------+------- ---------+
> | code | int(11) | | PRI | NULL | auto_increment |
> | date | varchar(250) | | | | |
> | nom | varchar(50) | YES | | NULL | |
> | email | varchar(50) | YES | | NULL | |
> | commentaire | blob | YES | | NULL | |
> +-------------+--------------+------+-----+---------+------- ---------+
> 5 rows in set (0.01 sec)
>

See http://www.mysql.com/documentation/mysql/bychapter/manual_Re ference.html#Silent_column_changes

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.


Regards,

Fred.


--
Fred van Engen XB Networks B.V.
email: fred.van.engen@xbn.nl Televisieweg 2
tel: +31 36 5462400 1322 AC Almere
fax: +31 36 5462424 The Netherlands

--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org