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.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eab129-202d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eab129-202d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?