更新:错误1265(01000):"数据在第1行和第34行的列中被截断;

时间:2014-07-17 07:13:30

标签: mysql sql

表模型(不好,但我必须处理..)

CREATE TABLE `vr_connection_param` (
   `connectionSize` enum('SMALL','MEDIUM','LARGE') COLLATE latin1_general_ci NOT NULL,
  `type` enum('OVP_BASIC','OVP_EXTENDED','TPASS') COLLATE latin1_general_ci NOT NULL,
  `numberConnection` smallint(5) unsigned DEFAULT NULL,
  PRIMARY KEY (`connectionSize`,`type`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci

记录的数据

select * from vr_connection_param;
+----------------+--------------+------------------+
| connectionSize | type         | numberConnection |
+----------------+--------------+------------------+
| SMALL          | OVP_BASIC    |                5 |
| SMALL          | OVP_EXTENDED |                5 |
| MEDIUM         | OVP_BASIC    |               10 |
| MEDIUM         | OVP_EXTENDED |               10 |
| LARGE          | OVP_BASIC    |               30 |
| LARGE          | OVP_EXTENDED |               30 |
+----------------+--------------+------------------+

尝试更新

update vr_connection_param
INNER JOIN
    (select distinct concat(`connectionSize`,`type`) from vr_connection_param where concat(`connectionSize`,`type`) like '%OVP_BASIC%') 
    AS TMP
SET type='OVPFE_EXPRESS';

错误返回

ERROR 1265 (01000): Data truncated for column 'type' at row 1

1 个答案:

答案 0 :(得分:2)

您尝试在'OVPFE_EXPRESS'列中设置值type,该值enum不包含该值。因此,根据我的MySQL安装,该值被“截断”(显示为''


同样值得注意的是,你的陈述的整个INNER JOIN部分都是无操作的,因为你没有对TMP做任何事情。因此,您只需{(1}}进行(有效)否UPDATE