This topic describes how to handle ERROR 1265, where data was truncated while being inserted to OceanBase Database in MySQL mode.
Symptom
When data is inserted into the ty table, an error is reported indicating that the data was truncated.
obclient> INSERT INTO ty VALUE('1970-01-01');
ERROR 1265 (01000): Data truncated for argument
The error codes corresponding to this error message are as follows:
Error code: ERROR 1265
Error code in OceanBase Database: 4249
MySQL error code: 1265
For more information about the error codes, see Error code overview.
Possible causes
The length of the inserted value exceeds the maximum length allowed for the column.
Troubleshooting procedure
Perform the following steps to view the type and length of each field in the current table and insert an invalid value.
View the schema of the current table
ty.obclient> DESC ty; +-------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | c1 | year(4) | YES | | NULL | | +-------+---------+------+-----+---------+-------+ 1 row in setInsert a valid value based on the field type.
obclient> INSERT INTO ty VALUE('1970'); Query OK, 1 row affectedView the inserted data. Data is properly inserted.
obclient> SELECT * FROM ty; +------+ | c1 | +------+ | 1970 | +------+ 1 row in set