Hi,
if varchar represents decimal(6,x) where x>2, it's truncated. Else, it's
converted :


mysql> create table dcml (a varchar(10));
Query OK, 0 rows affected (0.24 sec)

mysql> insert into dcml values('16.00'),('16.25'),('16.125');
Query OK, 3 rows affected (0.05 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select * from dcml;
+--------+
| a      |
+--------+
| 16.00  |
| 16.25  |
| 16.125 |
+--------+
3 rows in set (0.03 sec)

mysql> alter table dcml modify a decimal(6,2);
Query OK, 3 rows affected, 1 warning (0.24 sec)
Records: 3  Duplicates: 0  Warnings: 1

mysql> show warnings;
+---------+------+----------------------------------------+
| Level   | Code | Message                                |
+---------+------+----------------------------------------+
| Warning | 1265 | Data truncated for column 'a' at row 3 |
+---------+------+----------------------------------------+
1 row in set (0.00 sec)

mysql> select * from dcml;
+-------+
| a     |
+-------+
| 16.00 |
| 16.25 |
| 16.12 |
+-------+
3 rows in set (0.00 sec)

Here, only row 3 is truncated !

Mathias



Selon Jerry Swanson <[EMAIL PROTECTED]>:

> decimal(6,2)
>
> On 5/18/05, Philippe Poelvoorde <[EMAIL PROTECTED]> wrote:
> > Jerry Swanson wrote:
> >
> > > I need to change format from varchar(10) to decimal.
> > > When I alter the table the data is trimmed.
> > >
> > > What I'm doing wrrong?
> > >
> > > TH
> > >
> >
> > ALTER TABLE your_table MODIFY your_column double NOT NULL DEFAULT '0.0';
> > should normally work. What is the command you are doing and have you
> > example results ?
> > How did you declare your decimal column ?
> >
> > --
> > Philippe Poelvoorde
> > COS Trading Ltd.
> >
> > --
> > MySQL General Mailing List
> > For list archives: http://lists.mysql.com/mysql
> > To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> >
> >
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to