简体   繁体   中英

Disable the retention of trailing spaces for VARCHAR columns

We are considering migrating from MySQL 4.x to MySQL 5.x.

However, beginning with MySQL 5.0.3, trailing spaces are retained in VARCHAR columns, whereas in MySQL 4.x, trailing spaces were not retained for VARCHAR columns.

It was suggested that there might be a MySQL setting that allows us to tell MySQL 5.x to behave as it did in MySQL 4.x, and not retain trailing spaces.

I'm unable to find such a setting, but maybe I'm overlooking it. Is there a way to do this?

AFAIK there is no SQL mode for reverting to the old behaviour. If your application relies on this behaviour your best bet might be to use BEFORE INSERT TRIGGERS to trim varchar values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM