View Feed
group-icon
Databases
Discuss databases and writing database queries with fellow DB enthusiasts.
296 Members
Join this group to post and comment.
Kaustubh Katdare
Kaustubh Katdare • Jul 15, 2019

What are the disadvantages of turning MySQL strict mode off?

I've ran into an issue which can be easily solved by turning off the "strict" mode in MySQL. I'm however not in favor of turning it off just to have my query work. 

Can someone inform me what are the disadvantages of disabling the strict mode? If I'm sanitizing all the data being sent to the DB; should I still care about the strict mode? 

Thank you in advance. 

Strict mode works exactly how it sounds.

As per my experience with mysql..

With strict mode off.. if you try to insert the long data compared to what the max length is defined..mysql will convert it to column datatype and truncate the value to max allowed limit. It means, you will not get an error. However with strict mode, data will not be inserted and error will be thrown.

Another example is datetime column being not null will not allow you to insert record without a valid value if strict mode is ON. With mode off, it will automatically insert the zero datetime value like 0000-00-00 00:00:00

More info here..

https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict

Upgrading to MySQL 5.7? Beware of the new STRICT mode




Share this content on your social channels -