Data truncation

2023-07-21 09:11:01  Updated

This topic describes errors related to data truncation and the troubleshooting procedure.

Error: ERROR 1265 (01000): Data truncated for column '%.*s' at row %ld

Error code

  • Error code in OceanBase Database: 4249

  • MySQL error code: 1265

Example

When you insert data into the ty table, this error is returned.

obclient> INSERT INTO ty VALUE('1970-01-01');
ERROR 1265 (01000): Data truncated for argument

Troubleshooting procedure

  1. View the schema of the ty table.

    obclient> DESC ty;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | c1    | year(4) | YES  |     | NULL    |       |
    +-------+---------+------+-----+---------+-------+
    1 row in set
    
  2. Insert a valid value based on the field type.

    obclient> INSERT INTO ty VALUE('1970');
    Query OK, 1 row affected
    
  3. View the inserted data.

    obclient> SELECT * FROM ty;
    +------+
    | c1   |
    +------+
    | 1970 |
    +------+
    1 row in set
    

Contact Us