Help Center/ Relational Database Service/ Troubleshooting/ RDS for MySQL/ SQL Issues/ "Data too long for column" Displayed When Data Is Inserted into an RDS for MySQL Instance
Updated on 2024-10-24 GMT+08:00

"Data too long for column" Displayed When Data Is Inserted into an RDS for MySQL Instance

Scenario

The following message is displayed when data is inserted into an RDS for MySQL instance through JDBC:

Data truncation: Data too long for column 'field_name'

Troubleshooting

Check whether the sql_mode parameter is set to STRICT_TRANS_TABLES at the session level.

STRICT_TRANS_TABLES indicates the strict mode. If sql_mode is set to STRICT_TRANS_TABLES, errors about long fields can be reported.

Solution

  • Increase the allowed field length during off-peak hours.

    ALTER TABLE table_name MODIFY COLUMN field_name VARCHAR(128);

  • Insert data through Data Admin Service (DAS). If there is overlong data, DAS truncates the data.