如果字段类型从字符型更变为数值型, 是不是原来的字符一律都会变成0? 原字段类型为var, 有部分数据为数值(如"100"),部分数据为字符("不限"),变更类型到数值型,如INT,是不是那些字符都变成0,数值的那些结果不变,只是类型变了?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 [email protected]_monitor>select * from test;+----+-------+| id | value |+----+-------+| 1 | 1 | | 2 | 2 | | 3 | 3 | | 4 | 5 | | 5 | 6 | | 6 | a | | 7 | b | | 8 | abc | +----+-------+8 rows in set (0.00 sec)[email protected]_monitor>alter table test modify value int;Query OK, 8 rows affected, 3 warnings (0.03 sec)Records: 8 Duplicates: 0 Warnings: [email protected]_monitor>select * from test;+----+-------+| id | value |+----+-------+| 1 | 1 | | 2 | 2 | | 3 | 3 | | 4 | 5 | | 5 | 6 | | 6 | 0 | | 7 | 0 | | 8 | 0 | +----+-------+8 rows in set (0.00 sec)当更改表内的数据列类型时,mysql会自动调用convert或者cast,我测试了一下[email protected]_monitor>select convert('a',UNSIGNED); +-----------------------+| convert('a',UNSIGNED) |+-----------------------+| 0 | +-----------------------+1 row in set, 1 warning (0.00 sec)mysql会直接将非数字转化成0 关于MySQL查询与插入 在mysql 里面 如何将一个整数和一个字符串拼接在一起 MYSQL IN的优化 关于MySql更新的问题,请高手帮帮忙! phpmyadmin2.8.2 无法显示数据表? create table using pl/sql with mysql mysql语句如何优化 4表连查,原来使用多视图太慢 求指导,sql优化的问题 #新手来袭#用sql语句如何实现查询上次查询之后的后面的数据 帮忙解决一个MySQL时区问题 更新数据表 mysql 如何监控表结构修改
+----+-------+
| id | value |
+----+-------+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 5 |
| 5 | 6 |
| 6 | a |
| 7 | b |
| 8 | abc |
+----+-------+
8 rows in set (0.00 sec)[email protected]_monitor>alter table test modify value int;
Query OK, 8 rows affected, 3 warnings (0.03 sec)
Records: 8 Duplicates: 0 Warnings: [email protected]_monitor>select * from test;
+----+-------+
| id | value |
+----+-------+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 5 |
| 5 | 6 |
| 6 | 0 |
| 7 | 0 |
| 8 | 0 |
+----+-------+
8 rows in set (0.00 sec)当更改表内的数据列类型时,mysql会自动调用convert或者cast,我测试了一下
[email protected]_monitor>select convert('a',UNSIGNED);
+-----------------------+
| convert('a',UNSIGNED) |
+-----------------------+
| 0 |
+-----------------------+
1 row in set, 1 warning (0.00 sec)
mysql会直接将非数字转化成0