Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UPDATE: ERROR 1265 (01000): "Data truncated for column at row 1"

Tags:

sql

mysql

table model (not good but i have to deal with..)

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

data recorded

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 |
+----------------+--------------+------------------+

try to update

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 returned

ERROR 1265 (01000): Data truncated for column 'type' at row 1
like image 654
user3847908 Avatar asked Dec 19 '25 01:12

user3847908


1 Answers

You're trying to set the value 'OVPFE_EXPRESS' in the type column which is an enum that doesn't contain that value. So the value is "truncated" (to '', apparently, according to my MySQL install).


It's also worth noting that the entire INNER JOIN part of your statement is a no-op, since you don't do anything with TMP. So you're just doing an UPDATE with (effectively) no WHERE.

like image 132
T.J. Crowder Avatar answered Dec 20 '25 18:12

T.J. Crowder