Inserting a string that exceeds the defined length into a field of string type in mysql does not intercept automatically, but directly reports an error.

mysql is a Mac version. Inserting data length that exceeds the length defined in the table class (figure 1 below) directly reports an error, rather than automatically solving it as in windows.

Table structure

insert into class(name) values("0123456789a");

:

Why is it different from Windows?

May.07,2021

caused by different sql_mode settings.
execute show variables like 'sql_mode'; should show include STRICT_TRANS_TABLES strict mode on mac, and include ANSI loose mode on windows.
specific sql_mode view portal .

to automatically intercept and insert more than the length, set sql_mode=ANSI;


Mysql version is different, default processing behavior is different

MySQL 5.5.*

clipboard.png

MySQL 5.7.*

clipboard.png


get.

Menu